Skip to content

Web3 Requester

List of supported rest calls to the Web3 endpoint

ERC20 Integration

The web3 requester integrates with the ERC20 module

The GetTotalSupply and GetBalanceERC20 can be used directly from the Client

supply, err := c.GetTotalSupply(contractAddress, height)
balance, err := c.GetBalanceERC20(contractAddress, wallet, height)

Get Block Number

Returns the current height of the network

height, err := c.GetBlockNumber()

GetBlockByNumber

Sending the height and whether you need the transactions or not will return the block data.

c.GetBlockByNumber(height, withTransactions)

GetTransactionTrace

Defaults the tracer to callTracer

c.GetTransactionTrace(hash)

GetTransactionReceipt

Gets the receipt for a given transaction hash

c.GetTransactionReceipt(hash)

GetTransactionReceiptWithRetry

Gets the receipt for a given transaction hash, it will use the second argument as the amount of retries.

Between retry attempts the process will wait one second. This function is useful to wait for the transaction to be included in a block.

c.GetTransactionReceiptWithRetry(hash, 10)

Get Nonce

Gets the current nonce for an account

nonce, err := c.GetNonce(address)

GasPrice

Gets current network's gas price

gasPrice, err := c.GasPrice()

NetworkID

Gets network's chain ID

chainID, err := c.ChainID()

Send Transaction

Broadcast the transaction object

txHash, err := c.BroadcastTX(tx)

Eth_call

Interacts with a public function exposed by the smartcontract at the given height

resp, err := client.EthCall(contract, callData, height)

Eth_code

Gets the smartcontract bytecode at the given height

resp, err := client.EthCode(contract, height)

Eth_code Hash

Gets the smartcontract bytecode hash at the latest height.

hash, err := client.EthCodeHash(contract, height)

GetContractAddress

Helper function that will try for 15 seconds to get the transaction receipt of the given transaction hash.

The transaction has must be on transaction that created a contract.

The helper function will also get the trace of the give transaction to ensure that there were not errors while deploying the contract.

address, err := client.GetContractAddress(txHash)