Sign and Broadcast Transaction
To sign and broadcast a transaction to the Cosmos network, follow these steps:
-
Prepare unsigned transactions in Base64 encrypted format.
-
Sign the transaction using your preferred Cosmos signing method.
-
Broadcast the signed transaction to the Cosmos network by making a POST request to /api/v1/cosmos/{network}/transaction/send.
Example request (for
cosmoshub-4
network):curl --request POST \ --url https://api-test.p2p.org/api/v1/cosmos/cosmoshub-4/transaction/send \ --header 'accept: application/json' \ --header 'authorization: Bearer <token>' \ --header 'content-type: application/json' \ --data ' { "signedTransaction": "0aab010a9b010a232f636f736d6f732e7374616b696e672e763162657461312e4d736744656c656761746512740a2d636f736d6f733179397765666d6c706d30646a6b74387373656576656b653068747466756b67326136306730721234636f736d6f7376616c6f70657231376c676730337a65397836786b613032667330686877346164347777673035686571723279381a0d0a057561746f6d120434323030120b546865206d65737361676512670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b0c7ac278e1941ac0b65d6bd45d541cae58aa584058fbbd822311b8718708c0e12040a020801181312130a0d0a057561746f6d12043539353210dfc30e1a4026d73408f2f516a2a26604cb5a63f3d57262a4462d10931c21d36c1ce9d73d8f7d051f1c4aabc2e3142c7f01a4935b85c5c7d3854e8a3c41f0c218daf2a7b5ef" }'
signedTransaction
— signed transaction in Base64 encrypted format which needs to be broadcast to the network.
Example response:
{ "error": null, "result": { "status": "success", "blockId": 18575267, "fee": 0.005952, "gas": { "used": 202947, "wanted": 238047 }, "transactionHash": "ADD7B2791E1959075D1836D4BCC71ED256CCD724459F9BD8862D85E205075D47" } }
status
— transaction status:success
,failed
.blockId
— unique identifier of the block in which the transaction has been included.fee
— total fee in ATOM charged for processing the transaction.gas
— computational effort required to execute the transaction, measured in gas units.used
— amount of gas spent for the transaction.wanted
— maximum gas limit that the transaction initiator was willing to consume for the transaction.
transactionHash
— hash of the transaction.
What's Next?- Getting Started.
- Withdrawal.
- Staking API reference.
Updated 10 months ago