Querying the Blockchain

Once you have imported Brambl, you can do many read-only requests without needing to import any other modules which you can use to query the current state, fetch historical information, and so on.

Requests Available in Both JS and SC

Get Latest Block: Requests the latest block from the chain provider (SC) or network (JS)

brambl.requests.getLatestBlock();

Get a particular block by height

// Get Block by Height

brambl.requests.getBlockByHeight({"height": 3});

Get the balance on addresses

val params: Balances.Params = ToplRpc.NodeView.Balances.Params(externalAddress.toList)
val response: RpcErrorOr[Balances.Response] = ToplRpc.NodeView.Balances.rpc(params)

Get the latest 100 transactions from the Mempool

brambl.requests.getMempool();

Lookup an UNCONFIRMED transaction by id (a transaction in the mempool)

brambl.requests.getTransactionFromMempool({transactionId: "txId"})
val response: RpcErrorOr[Mempool.Response] = ToplRpc.NodeView.Mempool.rpc(params)

Lookup a CONFIRMED transaction by id (a transaction in a block)

brambl.requests.getTransactionById({transactionId: txId});

Lookup Block by Id

brambl.requests.getBlockById({blockId: "blockId"})