Signing
Sign messages and transactions on Cosmos chains
Learn how to sign transactions and messages using OneKey's Cosmos provider.
Sign Amino (Legacy)
For legacy Amino-encoded transactions:
const chainId = 'cosmoshub-4'
const signer = 'cosmos1...'
const signDoc = {
chain_id: chainId,
account_number: '0',
sequence: '0',
fee: {
amount: [{ denom: 'uatom', amount: '5000' }],
gas: '200000',
},
msgs: [{
type: 'cosmos-sdk/MsgSend',
value: {
from_address: signer,
to_address: 'cosmos1...',
amount: [{ denom: 'uatom', amount: '1000000' }],
},
}],
memo: '',
}
const result = await provider.signAmino(chainId, signer, signDoc)
console.log({
signed: result.signed, // Signed document
signature: result.signature, // { pub_key, signature }
})Sign Direct (Protobuf)
For modern Protobuf-encoded transactions:
Sign Arbitrary Data
For signing arbitrary messages (useful for authentication):
Broadcast Transaction
Sign Ethereum Data
For chains that support Ethereum signing (like Evmos):
Error Handling
Last updated
Was this helpful?