Ethereum

GetCode

GetCode returns code at a given address.

code, err := client.Eth().GetCode(address, block)

Params:

  • address (Address): Address of the contract to query.
  • block (BlockTag): Block reference to query the data.

Output:

  • code ([]byte): Bytecode of the contract.

Accounts

Accounts returns a list of addresses owned by client. This endpoint is not enabled in infrastructure providers.

accounts, err := client.Eth().Accounts()

Output:

  • accounts ([]Address): List of addresses registered in the client.

GetStorageAt

GetStorageAt returns the value from a storage position at a given address.

storage, err := client.Eth().GetStorageAt(addr, slot, block)

Params:

  • addr (Address): Address to query.
  • slot (Hash): Slot storage for the address.
  • block (BlockTag): Block reference to query the data.

Output:

  • storage ([]byte): Content of the storage.

BlockNumber

BlockNumber returns the number of most recent block.

number, err := client.Eth().BlockNumber()

Output:

  • number (uint): Number of the most recent block.

GetBlockByNumber

GetBlockByNumber returns information about a block by block number.

block, err := client.Eth().GetBlockByNumber(num, full)

Params:

  • number (uint): Number of the block to query.
  • full (bool): Whether the ouput block should include transactions.

Output:

GetBlockByHash

GetBlockByHash returns information about a block by hash.

block, err := client.Eth().GetBlockByHash(hash, full)

Params:

  • hash (Hash): Hash of the block to query.
  • full (bool): Whether the ouput block should include transactions.

Output:

GetTransactionByHash

GetTransactionByHash returns a transaction by his hash

transaction, err := client.Eth().GetTransactionByHash(hash)

Params:

  • hash (Hash): Hash of the transaction to query.

Output:

SendRawTransaction

SendRawTransaction creates new message call transaction or a contract creation for signed transactions.

hash, err := client.Eth().SendRawTransaction(transaction)

Params:

  • transaction ([]byte): Signed transaction and encoded in RLP format.

Output:

  • hash (Hash): Hash of the transaction created.

GetTransactionReceipt

GetTransactionReceipt returns the receipt of a transaction by transaction hash.

receipt, err := client.Eth().GetTransactionReceipt(hash)

Params:

  • hash (Hash): Hash of the transaction being queried.

Output:

GetNonce

GetNonce returns the number of transactions sent from an address.

nonce, err := client.Eth().GetNonce(address)

Params:

  • address (Address): address of the account to query.

Output:

  • nonce (uint64): next valid nonce for the account.

GetBalance

GetBalance returns the balance of the account of given address.

balance, err := client.Eth().GetBalance(address)

Params:

  • address (Address): address of the account to query.

Output:

  • balance (big.Int): balance of the account in big format.

GasPrice

GasPrice returns the current price per gas in wei.

price, err := client.Eth().GasPrice()

Output:

  • price (big.Int): gas price in wei.