Broadcast to a Node
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. You can leave all signature fields empty because simulations do not check any signatures. In our signing examples (previous pages), simply set simulate = true.
// https://api.bitbadges.io/api/v0/simulate
const res = await BitBadgesApi.simulateTx(txBody); //Returned from signing stepsThis will return the gas used and success statuses on a dry run of the transaction.
export interface SimulateTxRouteSuccessResponse<T extends NumberType> {
gas_info: {
gas_used: string;
gas_wanted: string;
};
result: {
data: string;
log: string;
events: {
type: string;
attributes: {
key: string;
value: string;
index: boolean;
}[];
}[];
msg_responses: any[];
};
}Broadcasting
You can replace the URL below with any valid BitBadges blockchain node.
The response code should be 0 for a successful transaction.
Polling
Once you have the tx hash from above, you can poll a node until the transaction is confirmed like below. Note this is a blockchain REST API_URL, not the BitBadges API. Use https://lcd.bitbadges.io for the BitBadges maintained node.
There are also other polling methods: websockets + parsing txs as they come through, the Cosmos SDK provides various endpoints / approaches, redirecting to explorers.
Last updated