Broadcasting a transaction
The DEMOS transaction broadcasting system works as a 2 step process.Step 1: Gas fee confirmation
The confirmation process starts by a client sending the transaction to the node. The node analyses the workload and returns information on how much gas is needed to execute your transaction.gas_operation.params.amount), you can proceed to broadcasting the tx.
Your public key and public key signature are sent along with the request for verification. You need to have your KeyPair connected to the
demos object.Step 2: Broadcasting the validity data
To execute your transaction, send back the validity data to the node.Broadcast and wait for inclusion
demos.broadcast() returns as soon as the node accepts the transaction; it does not wait for the transaction to be included in a block. If you need a deterministic confirmation, use demos.broadcastAndWait() (added in v2.12.0). It broadcasts and then polls the node’s getTransactionStatus RPC until the transaction reaches a terminal state — included or failed — or the timeout elapses.
DemosTransactions.broadcastAndWait(validityData, demos, opts) accepts an additional failFastOnBroadcastError flag. When set to true, the call throws BroadcastFailedError immediately if the broadcast itself can’t reach the node (e.g. ECONNREFUSED, ENOTFOUND). HTTP 5xx responses are not treated as fail-fast — the server did answer, so the tx may still have landed and the SDK keeps polling.
Error types
The transport layer surfaces a small, focused set of typed errors. Catch them by class to handle each case precisely:Retry semantics
The transport layer automatically retries on HTTP 5xx responses and honoursRetry-After headers (seconds or HTTP-date). Backoff is capped at 8 seconds (MAX_BACKOFF_MS) so a misbehaving node cannot stall the SDK indefinitely. The attempts count surfaced by TransportError reflects the total number of attempts including the final failing one.
rpcCall and _doPost retry independently — _doPost retries on transport-level failures, rpcCall retries on RPC-level errors — so retry budgets do not multiply across layers.