Broadcast to a Node
Pre-Req: You have the body variable with a valid signature (see prior pages).
Simulating
A good practice to have is to simulate the transaction before you actually broadcast and update the fee from the transaction context with up to date values.
To do this, you can use
or
This will return the gas used on a dry run of the transaction and any errors if it finds any. You can leave all signature fields empty because simulations do not check any signatures.
Note this tutorial is slightly out of order for clarity, the simulation step should typically be done before the user signs, so they only have to sign the final Msg with the up to date gas.
Once simulated, replace the expected gas you want in the transaction context.
Broadcasting
You can replace the URL below with any valid BitBadges blockchain node.
Or, you can use the BitBadges API to broadcast.
This will give you a response immediately. You should then use the tx_response.txhash to view it on an explorer, query the blockchain directly, see if it had errors, and so on. The response code should be 0 for a successful transaction. We refer you to Cosmos docs for more information about each indivdual item.
Polling
Once you have the tx hash, you can poll a node until the transaction is confirmed like below. Note this is a blockchain REST API_URL, not the BitBadges API. You can also view it on explorers.
Use http://node.bitbadges.io:1317 or one of the aliases below for the BitBadges maintained node.
http://134.122.12.165:1317
https://node.bitbadges.io/api
Last updated