Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • default

Implements

  • Api

Indexable

[index: string]: (...args: any) => Promise<any>
    • (...args: any): Promise<any>
    • Parameters

      • Rest ...args: any

      Returns Promise<any>

Index

Constructors

Properties

Methods

Constructors

constructor

  • new default(options: EthereumInternalOptions, wallet: default, blockchain: default): default
  • This is the Ethereum API that the provider interacts with. The only methods permitted on the prototype are the supported json-rpc methods.

    Parameters

    • options: EthereumInternalOptions
    • wallet: default
    • blockchain: default

    Returns default

Properties

Private Readonly #blockchain

#blockchain: default

Private Readonly #filters

#filters: Map<string, InternalFilter> = ...

Private Readonly #getId

#getId: () => Quantity = ...

Type declaration

    • (): Quantity
    • Returns Quantity

Private Readonly #options

#options: EthereumInternalOptions

Private Readonly #subscriptions

#subscriptions: Map<string, UnsubscribeFn> = ...

Private Readonly #wallet

#wallet: default

Methods

bzz_hive

  • bzz_hive(): Promise<any[]>
  • Returns the kademlia table in a readable table format.

    example
    console.log(await provider.send("bzz_hive"));
    

    Returns Promise<any[]>

    Returns the kademlia table in a readable table format.

bzz_info

  • bzz_info(): Promise<any[]>
  • Returns details about the swarm node.

    example
    console.log(await provider.send("bzz_info"));
    

    Returns Promise<any[]>

    Returns details about the swarm node.

db_getHex

  • db_getHex(dbName: string, key: string): Promise<string>
  • Returns binary data from the local database.

    example
    console.log(await provider.send("db_getHex", ["testDb", "testKey"] ));
    

    Parameters

    • dbName: string

      Database name.

    • key: string

      Key name.

    Returns Promise<string>

    The previously stored data.

db_getString

  • db_getString(dbName: string, key: string): Promise<string>
  • Returns string from the local database.

    example
    console.log(await provider.send("db_getString", ["testDb", "testKey"] ));
    

    Parameters

    • dbName: string

      Database name.

    • key: string

      Key name.

    Returns Promise<string>

    The previously stored string.

db_putHex

  • db_putHex(dbName: string, key: string, data: string): Promise<boolean>
  • Stores binary data in the local database.

    example
    console.log(await provider.send("db_putHex", ["testDb", "testKey", "0x0"] ));
    

    Parameters

    • dbName: string

      Database name.

    • key: string

      Key name.

    • data: string

      Data to store.

    Returns Promise<boolean>

    true if the value was stored, otherwise false.

db_putString

  • db_putString(dbName: string, key: string, value: string): Promise<boolean>
  • Stores a string in the local database.

    example
    console.log(await provider.send("db_putString", ["testDb", "testKey", "testValue"] ));
    

    Parameters

    • dbName: string

      Database name.

    • key: string

      Key name.

    • value: string

      String to store.

    Returns Promise<boolean>

    returns true if the value was stored, otherwise false.

debug_storageRangeAt

  • debug_storageRangeAt(blockHash: string, transactionIndex: number, contractAddress: string, startKey: string, maxResult: number): Promise<StorageRangeAtResult>
  • Attempts to replay the transaction as it was executed on the network and return storage data given a starting key and max number of entries to return.

    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const initialTxHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard

    const {contractAddress} = await provider.request({ method: "eth_getTransactionReceipt", params: [initialTxHash] });

    // set value to 19
    const data = "0x552410770000000000000000000000000000000000000000000000000000000000000019";
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to: contractAddress, data }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard

    const { blockHash, transactionIndex } = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
    const storage = await provider.request({ method: "debug_storageRangeAt", params: [blockHash, transactionIndex, contractAddress, "0x01", 1] });
    console.log(storage);

    Parameters

    • blockHash: string

      Hash of a block.

    • transactionIndex: number

      Integer of the transaction index position.

    • contractAddress: string

      Address of the contract.

    • startKey: string

      Hash of the start key for grabbing storage entries.

    • maxResult: number

      Integer of maximum number of storage entries to return.

    Returns Promise<StorageRangeAtResult>

    Returns a storage object with the keys being keccak-256 hashes of the storage keys, and the values being the raw, unhashed key and value for that specific storage slot. Also returns a next key which is the keccak-256 hash of the next key in storage for continuous downloading.

debug_traceTransaction

  • debug_traceTransaction(transactionHash: string, options?: TraceTransactionOptions): Promise<TraceTransactionResult>
  • Attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.

    In addition to the hash of the transaction you may give it a secondary optional argument, which specifies the options for this specific call. The possible options are:

    • disableStorage: {boolean} Setting this to true will disable storage capture (default = false).
    • disableMemory: {boolean} Setting this to true will disable memory capture (default = false).
    • disableStack: {boolean} Setting this to true will disable stack capture (default = false).
    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const transactionTrace = await provider.request({ method: "debug_traceTransaction", params: [txHash] });
    console.log(transactionTrace);

    Parameters

    • transactionHash: string

      Hash of the transaction to trace.

    • Optional options: TraceTransactionOptions

      See options in source.

    Returns Promise<TraceTransactionResult>

    Returns the gas, structLogs, and returnValue for the traced transaction.

    The structLogs are an array of logs, which contains the following fields:

    • depth: The execution depth.
    • error: Information about an error, if one occurred.
    • gas: The number of gas remaining.
    • gasCost: The cost of gas in wei.
    • memory: An array containing the contract's memory data.
    • op: The current opcode.
    • pc: The current program counter.
    • stack: The EVM execution stack.
    • storage: An object containing the contract's storage data.

eth_accounts

  • eth_accounts(): Promise<string[]>
  • Returns a list of addresses owned by client.

    example
    const accounts = await provider.request({ method: "eth_accounts", params: [] });
    console.log(accounts);

    Returns Promise<string[]>

    Array of 20 Bytes - addresses owned by the client.

eth_blockNumber

  • eth_blockNumber(): Promise<Quantity>
  • Returns the number of the most recent block.

    example
    const blockNumber = await provider.request({ method: "eth_blockNumber" });
    console.log(blockNumber);

    Returns Promise<Quantity>

    The current block number the client is on.

eth_call

  • eth_call(transaction: Transaction, blockNumber?: string, overrides?: CallOverrides): Promise<Data>
  • Executes a new message call immediately without creating a transaction on the block chain.

    Transaction call object:

    • from: DATA, 20 bytes (optional) - The address the transaction is sent from.
    • to: DATA, 20 bytes - The address the transaction is sent to.
    • gas: QUANTITY (optional) - Integer of the maximum gas allowance for the transaction.
    • gasPrice: QUANTITY (optional) - Integer of the price of gas in wei.
    • value: QUANTITY (optional) - Integer of the value in wei.
    • data: DATA (optional) - Hash of the method signature and the ABI encoded parameters.

    State Override object - An address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing the call. Each address maps to an object containing:

    • balance: QUANTITY (optional) - The balance to set for the account before executing the call.
    • nonce: QUANTITY (optional) - The nonce to set for the account before executing the call.
    • code: DATA (optional) - The EVM bytecode to set for the account before executing the call.
    • state: OBJECT (optional*) - Key-value mapping to override all slots in the account storage before executing the call.
    • stateDiff: OBJECT (optional*) - Key-value mapping to override individual slots in the account storage before executing the call.
    • *Note - state and stateDiff fields are mutually exclusive.
    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    const txObj = { from, gas: "0x5b8d80", gasPrice: "0x1dfd14000", value:"0x0", data: simpleSol };
    const slot = "0x0000000000000000000000000000000000000000000000000000000000000005"
    const overrides = { [from]: { balance: "0x3e8", nonce: "0x5", code: "0xbaddad42", stateDiff: { [slot]: "0x00000000000000000000000000000000000000000000000000000000baddad42"}}};
    const result = await provider.request({ method: "eth_call", params: [txObj, "latest", overrides] });
    console.log(result);

    Parameters

    • transaction: Transaction

      The transaction call object as seen in source.

    • blockNumber: string = Tag.latest

      Integer block number, or the string "latest", "earliest" or "pending".

    • overrides: CallOverrides = {}

      State overrides to apply during the simulation.

    Returns Promise<Data>

    The return value of executed contract.

eth_chainId

  • eth_chainId(): Promise<Quantity>
  • Returns the currently configured chain id, a value used in replay-protected transaction signing as introduced by EIP-155.

    eip

    155 – Simple replay attack protection

    example
    const chainId = await provider.send("eth_chainId");
    console.log(chainId);

    Returns Promise<Quantity>

    The chain id as a string.

eth_coinbase

  • eth_coinbase(): Promise<Address>
  • Returns the client coinbase address.

    example
    const coinbaseAddress = await provider.request({ method: "eth_coinbase" });
    console.log(coinbaseAddress);

    Returns Promise<Address>

    The current coinbase address.

eth_estimateGas

  • eth_estimateGas(transaction: Transaction, blockNumber?: string): Promise<Quantity>
  • Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.

    Transaction call object:

    • from: DATA, 20 bytes (optional) - The address the transaction is sent from.
    • to: DATA, 20 bytes - The address the transaction is sent to.
    • gas: QUANTITY (optional) - Integer of the maximum gas allowance for the transaction.
    • gasPrice: QUANTITY (optional) - Integer of the price of gas in wei.
    • value: QUANTITY (optional) - Integer of the value in wei.
    • data: DATA (optional) - Hash of the method signature and the ABI encoded parameters.
    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    const gasEstimate = await provider.request({ method: "eth_estimateGas", params: [{ from, to }, "latest" ] });
    console.log(gasEstimate);

    Parameters

    • transaction: Transaction

      The transaction call object as seen in source.

    • blockNumber: string = Tag.latest

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Quantity>

    The amount of gas used.

eth_feeHistory

  • eth_feeHistory(blockCount: string, newestBlock: string, rewardPercentiles: number[]): Promise<FeeHistory>
  • Returns a collection of historical block gas data and optional effective fee spent per unit of gas for a given percentile of block gas usage.

    eip

    1559 - Fee market change

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_sendTransaction", params: [{ from, to }] });
    const feeHistory = await provider.request({ method: "eth_feeHistory", params: ["0x1", "0x1", [10, 100]] });
    console.log(feeHistory);

    Parameters

    • blockCount: string

      Range of blocks between 1 and 1024. Will return less than the requested range if not all blocks are available.

    • newestBlock: string

      Highest block of the requested range.

    • rewardPercentiles: number[]

      A monotonically increasing list of percentile values. For each block in the requested range, the transactions will be sorted in ascending order by effective tip per gas and the corresponding effective tip for the percentile will be determined, accounting for gas consumed.

    Returns Promise<FeeHistory>

    transaction base fee per gas and effective priority fee per gas for the requested/supported block range

    • oldestBlock: - Lowest number block of the returned range.
    • baseFeePerGas: - An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.
    • gasUsedRatio: - An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit.
    • reward: - An array of effective priority fee per gas data points from a single block. All zeroes are returned if the block is empty.

eth_gasPrice

  • eth_gasPrice(): Promise<Quantity>
  • Returns the current price per gas in wei.

    example
    const gasPrice = await provider.request({ method: "eth_gasPrice", params: [] });
    console.log(gasPrice);

    Returns Promise<Quantity>

    Integer of the current gas price in wei.

eth_getBalance

  • eth_getBalance(address: string, blockNumber?: string): Promise<Quantity>
  • Returns the balance of the account of given address.

    example
    const accounts = await provider.request({ method: "eth_accounts", params: [] });
    const balance = await provider.request({ method: "eth_getBalance", params: [accounts[0], "latest"] });
    console.log(balance);

    Parameters

    • address: string

      Address to check for balance.

    • blockNumber: string = Tag.latest

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Quantity>

    Integer of the account balance in wei.

eth_getBlockByHash

  • eth_getBlockByHash<IncludeTransactions>(hash: string, transactions?: IncludeTransactions): Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>
  • Returns information about a block by block hash.

    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
    const block = await provider.request({ method: "eth_getBlockByHash", params: [txReceipt.blockHash, true] });
    console.log(block);

    Type parameters

    • IncludeTransactions: boolean = false

    Parameters

    • hash: string

      Hash of a block.

    • Optional transactions: IncludeTransactions

      If true it returns the full transaction objects, if false only the hashes of the transactions.

    Returns Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>

    The block, null if the block doesn't exist.

    • hash: DATA, 32 Bytes - Hash of the block. null when pending.
    • parentHash: DATA, 32 Bytes - Hash of the parent block.
    • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.
    • miner: DATA, 20 Bytes - Address of the miner.
    • stateRoot: DATA, 32 Bytes - The root of the state trie of the block.
    • transactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block.
    • receiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block.
    • logsBloom: DATA, 256 Bytes - The bloom filter for the logs of the block. null when pending.
    • difficulty: QUANTITY - Integer of the difficulty of this block.
    • number: QUANTITY - The block number. null when pending.
    • gasLimit: QUANTITY - The maximum gas allowed in the block.
    • gasUsed: QUANTITY - Total gas used by all transactions in the block.
    • timestamp: QUANTITY - The unix timestamp for when the block was collated.
    • extraData: DATA - Extra data for the block.
    • mixHash: DATA, 256 Bytes - Hash identifier for the block.
    • nonce: DATA, 8 Bytes - Hash of the generated proof-of-work. null when pending.
    • totalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block.
    • size: QUANTITY - Integer the size of the block in bytes.
    • transactions: Array - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter.
    • uncles: Array - Array of uncle hashes.

eth_getBlockByNumber

  • eth_getBlockByNumber<IncludeTransactions>(number: string, transactions?: IncludeTransactions): Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>
  • Returns information about a block by block number.

    example
    const block = await provider.request({ method: "eth_getBlockByNumber", params: ["0x0", false] });
    console.log(block);

    Type parameters

    • IncludeTransactions: boolean = false

    Parameters

    • number: string

      Integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter.

    • Optional transactions: IncludeTransactions

      If true it returns the full transaction objects, if false only the hashes of the transactions.

    Returns Promise<{ hash: Data; size: Quantity; transactions: IncludeTransactions extends true ? (LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">)[] : Data[]; uncles: Data[] } & BlockHeader>

    The block, null if the block doesn't exist.

    • hash: DATA, 32 Bytes - Hash of the block. null when pending.
    • parentHash: DATA, 32 Bytes - Hash of the parent block.
    • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.
    • miner: DATA, 20 Bytes - Address of the miner.
    • stateRoot: DATA, 32 Bytes - The root of the state trie of the block.
    • transactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block.
    • receiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block.
    • logsBloom: DATA, 256 Bytes - The bloom filter for the logs of the block. null when pending.
    • difficulty: QUANTITY - Integer of the difficulty of this block.
    • number: QUANTITY - The block number. null when pending.
    • gasLimit: QUANTITY - The maximum gas allowed in the block.
    • gasUsed: QUANTITY - Total gas used by all transactions in the block.
    • timestamp: QUANTITY - The unix timestamp for when the block was collated.
    • extraData: DATA - Extra data for the block.
    • mixHash: DATA, 256 Bytes - Hash identifier for the block.
    • nonce: DATA, 8 Bytes - Hash of the generated proof-of-work. null when pending.
    • totalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block.
    • size: QUANTITY - Integer the size of the block in bytes.
    • transactions: Array - Array of transaction objects or 32 Bytes transaction hashes depending on the last parameter.
    • uncles: Array - Array of uncle hashes.

eth_getBlockTransactionCountByHash

  • eth_getBlockTransactionCountByHash(hash: string): Promise<Quantity>
  • Returns the number of transactions in a block from a block matching the given block hash.

    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
    const txCount = await provider.request({ method: "eth_getBlockTransactionCountByHash", params: [txReceipt.blockHash] });
    console.log(txCount);

    Parameters

    • hash: string

      Hash of a block.

    Returns Promise<Quantity>

    Number of transactions in the block.

eth_getBlockTransactionCountByNumber

  • eth_getBlockTransactionCountByNumber(blockNumber: string): Promise<Quantity>
  • Returns the number of transactions in a block from a block matching the given block number.

    example
    const txCount = await provider.request({ method: "eth_getBlockTransactionCountByNumber", params: ["0x0"] });
    console.log(txCount);

    Parameters

    • blockNumber: string

    Returns Promise<Quantity>

    Integer of the number of transactions in the block.

eth_getCode

  • eth_getCode(address: string, blockNumber?: string): Promise<Data>
  • Returns code at a given address.

    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
    const code = await provider.request({ method: "eth_getCode", params: [txReceipt.contractAddress, "latest"] });
    console.log(code);

    Parameters

    • address: string

      Address.

    • blockNumber: string = Tag.latest

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Data>

    The code from the given address.

eth_getCompilers

  • eth_getCompilers(): Promise<string[]>
  • Returns a list of available compilers.

    example
    const compilers = await provider.send("eth_getCompilers");
    console.log(compilers);

    Returns Promise<string[]>

    List of available compilers.

eth_getFilterChanges

  • eth_getFilterChanges(filterId: string): Promise<Data[]>
  • Polling method for a filter, which returns an array of logs, block hashes, or transaction hashes, depending on the filter type, which occurred since last poll.

    example
    // Logs.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    // contract Logs {
    // event Event(uint256 indexed first, uint256 indexed second);
    // constructor() {
    // emit Event(1, 2);
    // }
    //
    // function logNTimes(uint8 n) public {
    // for (uint8 i = 0; i < n; i++) {
    // emit Event(i, i);
    // }
    // }
    // }

    const logsContract = "0x608060405234801561001057600080fd5b50600260017f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a360e58061004f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80635e19e69f14602d575b600080fd5b605960048036036020811015604157600080fd5b81019080803560ff169060200190929190505050605b565b005b60005b8160ff168160ff16101560ab578060ff168160ff167f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a38080600101915050605e565b505056fea26469706673582212201af9c13c7b00e2b628c1258d45f9f62d2aad8cd32fc32fd9515d8ad1e792679064736f6c63430007040033";
    const [from] = await provider.send("eth_accounts");
    const filterId = await provider.send("eth_newFilter");

    const subscriptionId = await provider.send("eth_subscribe", ["newHeads"]);
    await provider.send("eth_sendTransaction", [{ from, data: logsContract, gas: "0x5b8d80" }] );
    await provider.once("message");

    const changes = await provider.request({ method: "eth_getFilterChanges", params: [filterId] });
    console.log(changes);

    await provider.send("eth_unsubscribe", [subscriptionId]);

    Parameters

    • filterId: string

      The filter id.

    Returns Promise<Data[]>

    An array of logs, block hashes, or transaction hashes, depending on the filter type, which occurred since last poll.

    For filters created with eth_newBlockFilter the return are block hashes (DATA, 32 Bytes).

    For filters created with eth_newPendingTransactionFilter the return are transaction hashes (DATA, 32 Bytes).

    For filters created with eth_newFilter the return are log objects with the following parameters:

    • removed: TAG - true when the log was removed, false if its a valid log.
    • logIndex: QUANTITY - Integer of the log index position in the block. null when pending.
    • transactionIndex: QUANTITY - Integer of the transactions index position. null when pending.
    • transactionHash: DATA, 32 Bytes - Hash of the transaction where the log was. null when pending.
    • blockHash: DATA, 32 Bytes - Hash of the block where the log was. null when pending.
    • blockNumber: QUANTITY - The block number where the log was in. null when pending.
    • address: DATA, 20 Bytes - The address from which the log originated.
    • data: DATA - Contains one or more 32 Bytes non-indexed arguments of the log.
    • topics: Array of DATA - Array of 0 to 4 32 Bytes DATA of indexed log arguments.

eth_getFilterLogs

  • eth_getFilterLogs(filterId: string): Promise<Logs>
  • Returns an array of all logs matching filter with given id.

    example
    // Logs.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    // contract Logs {
    // event Event(uint256 indexed first, uint256 indexed second);
    // constructor() {
    // emit Event(1, 2);
    // }
    //
    // function logNTimes(uint8 n) public {
    // for (uint8 i = 0; i < n; i++) {
    // emit Event(i, i);
    // }
    // }
    // }

    const logsContract = "0x608060405234801561001057600080fd5b50600260017f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a360e58061004f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80635e19e69f14602d575b600080fd5b605960048036036020811015604157600080fd5b81019080803560ff169060200190929190505050605b565b005b60005b8160ff168160ff16101560ab578060ff168160ff167f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a38080600101915050605e565b505056fea26469706673582212201af9c13c7b00e2b628c1258d45f9f62d2aad8cd32fc32fd9515d8ad1e792679064736f6c63430007040033";
    const [from] = await provider.send("eth_accounts");
    const filterId = await provider.send("eth_newFilter");

    await provider.send("eth_subscribe", ["newHeads"]);
    await provider.send("eth_sendTransaction", [{ from, data: logsContract, gas: "0x5b8d80" }] );
    await provider.once("message");

    const logs = await provider.request({ method: "eth_getFilterLogs", params: [filterId] });
    console.log(logs);

    Parameters

    • filterId: string

      The filter id.

    Returns Promise<Logs>

    Array of log objects, or an empty array.

eth_getLogs

  • eth_getLogs(filter: FilterArgs): Promise<Logs>
  • Returns an array of all logs matching a given filter object.

    Filter options:

    • fromBlock: QUANTITY | TAG (optional) - Integer block number, or the string "latest", "earliest" or "pending".
    • toBlock: QUANTITY | TAG (optional) - Integer block number, or the string "latest", "earliest" or "pending".
    • address: DATA | Array (optional) - Contract address or a list of addresses from which the logs should originate.
    • topics: Array of DATA (optional) - Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
    • blockHash: DATA, 32 Bytes (optional) - Hash of the block to restrict logs from. If blockHash is present, then neither fromBlock or toBlock are allowed.
    example
    // Logs.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    // contract Logs {
    // event Event(uint256 indexed first, uint256 indexed second);
    // constructor() {
    // emit Event(1, 2);
    // }
    //
    // function logNTimes(uint8 n) public {
    // for (uint8 i = 0; i < n; i++) {
    // emit Event(i, i);
    // }
    // }
    // }

    const logsContract = "0x608060405234801561001057600080fd5b50600260017f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a360e58061004f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80635e19e69f14602d575b600080fd5b605960048036036020811015604157600080fd5b81019080803560ff169060200190929190505050605b565b005b60005b8160ff168160ff16101560ab578060ff168160ff167f34e802e5ebd1f132e05852c5064046c1b535831ec52f1c4997fc6fdc4d5345b360405160405180910390a38080600101915050605e565b505056fea26469706673582212201af9c13c7b00e2b628c1258d45f9f62d2aad8cd32fc32fd9515d8ad1e792679064736f6c63430007040033";
    const [from] = await provider.send("eth_accounts");

    await provider.send("eth_subscribe", ["newHeads"]);
    const txHash = await provider.send("eth_sendTransaction", [{ from, data: logsContract, gas: "0x5b8d80" }] );
    await provider.once("message");

    const { contractAddress } = await provider.send("eth_getTransactionReceipt", [txHash] );

    const logs = await provider.request({ method: "eth_getLogs", params: [{ address: contractAddress }] });
    console.log(logs);

    Parameters

    • filter: FilterArgs

      The filter options as seen in source.

    Returns Promise<Logs>

    Array of log objects, or an empty array.

eth_getProof

  • eth_getProof(address: string, storageKeys: string[], blockNumber?: string): Promise<AccountProof>
  • Returns the details for the account at the specified address and block number, the account's Merkle proof, and the storage values for the specified storage keys with their Merkle-proofs.

    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
    const proof = await provider.request({ method: "eth_getProof", params: [txReceipt.contractAddress, ["0x0", "0x1"], "latest"] });
    console.log(proof);

    Parameters

    • address: string

      Address of the account

    • storageKeys: string[]

      Array of storage keys to be proofed.

    • blockNumber: string = Tag.latest

      A block number, or the string "earliest", "latest", or "pending".

    Returns Promise<AccountProof>

    An object containing the details for the account at the specified address and block number, the account's Merkle proof, and the storage-values for the specified storage keys with their Merkle-proofs:

    • balance: QUANTITY - the balance of the account.
    • codeHash: DATA - 32 Bytes - hash of the account. A simple account without code will return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
    • nonce: QUANTITY - the nonce of the account.
    • storageHash: DATA - 32 Bytes - SHA3 of the StorageRoot. All storage will deliver a MerkleProof starting with this rootHash.
    • accountProof: Array - Array of rlp-serialized MerkleTree-Nodes, starting with the stateRoot-NODE, following the path of the SHA3 (address) as key.
    • storageProof: Array - Array of storage entries as requested. Each entry is an object with the following properties:
      • key: DATA - the requested storage key.
      • value: QUANTITY - the storage value.
      • proof: Array - Array of rlp-serialized MerkleTree-Nodes, starting with the storageHash-Node, following the path of the SHA3 (key) as path.

eth_getStorageAt

  • eth_getStorageAt(address: string, position: string, blockNumber?: string): Promise<Data>
  • Returns the value from a storage position at a given address.

    example
    // Simple.sol
    // // SPDX-License-Identifier: MIT
    // pragma solidity ^0.7.4;
    //
    // contract Simple {
    // uint256 public value;
    // constructor() payable {
    // value = 5;
    // }
    // }
    const simpleSol = "0x6080604052600560008190555060858060196000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80633fa4f24514602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea26469706673582212200897f7766689bf7a145227297912838b19bcad29039258a293be78e3bf58e20264736f6c63430007040033";
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", data: simpleSol }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });
    const storageValue = await provider.request({ method: "eth_getStorageAt", params: [txReceipt.contractAddress, "0x0", "latest"] });
    console.log(storageValue);

    Parameters

    • address: string

      Address of the storage.

    • position: string

      Integer of the position in the storage.

    • blockNumber: string = Tag.latest

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Data>

    The value in storage at the requested position.

eth_getTransactionByBlockHashAndIndex

  • eth_getTransactionByBlockHashAndIndex(hash: string, index: string): Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>
  • Returns information about a transaction by block hash and transaction index position.

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const { blockHash, transactionIndex } = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });

    const tx = await provider.request({ method: "eth_getTransactionByBlockHashAndIndex", params: [ blockHash, transactionIndex ] });
    console.log(tx);

    Parameters

    • hash: string

      Hash of a block.

    • index: string

      Integer of the transaction index position.

    Returns Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>

    The transaction object or null if no transaction was found.

    • hash: DATA, 32 Bytes - The transaction hash.
    • nonce: QUANTITY - The number of transactions made by the sender prior to this one.
    • blockHash: DATA, 32 Bytes - The hash of the block the transaction is in. null when pending.
    • blockNumber: QUANTITY - The number of the block the transaction is in. null when pending.
    • transactionIndex: QUANTITY - The index position of the transaction in the block.
    • from: DATA, 20 Bytes - The address the transaction is sent from.
    • to: DATA, 20 Bytes - The address the transaction is sent to.
    • value: QUANTITY - The value transferred in wei.
    • gas: QUANTITY - The gas provided by the sender.
    • gasPrice: QUANTITY - The price of gas in wei.
    • input: DATA - The data sent along with the transaction.
    • v: QUANTITY - ECDSA recovery id.
    • r: DATA, 32 Bytes - ECDSA signature r.
    • s: DATA, 32 Bytes - ECDSA signature s.

eth_getTransactionByBlockNumberAndIndex

  • eth_getTransactionByBlockNumberAndIndex(number: string, index: string): Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>
  • Returns information about a transaction by block number and transaction index position.

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    const { transactionIndex } = await provider.request({ method: "eth_getTransactionReceipt", params: [txHash] });

    const tx = await provider.request({ method: "eth_getTransactionByBlockNumberAndIndex", params: [ "latest", transactionIndex ] });
    console.log(tx);

    Parameters

    • number: string

      A block number, or the string "earliest", "latest" or "pending".

    • index: string

      Integer of the transaction index position.

    Returns Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON>

    The transaction object or null if no transaction was found.

    • hash: DATA, 32 Bytes - The transaction hash.
    • nonce: QUANTITY - The number of transactions made by the sender prior to this one.
    • blockHash: DATA, 32 Bytes - The hash of the block the transaction is in. null when pending.
    • blockNumber: QUANTITY - The number of the block the transaction is in. null when pending.
    • transactionIndex: QUANTITY - The index position of the transaction in the block.
    • from: DATA, 20 Bytes - The address the transaction is sent from.
    • to: DATA, 20 Bytes - The address the transaction is sent to.
    • value: QUANTITY - The value transferred in wei.
    • gas: QUANTITY - The gas provided by the sender.
    • gasPrice: QUANTITY - The price of gas in wei.
    • input: DATA - The data sent along with the transaction.
    • v: QUANTITY - ECDSA recovery id.
    • r: DATA, 32 Bytes - ECDSA signature r.
    • s: DATA, 32 Bytes - ECDSA signature s.

eth_getTransactionByHash

  • eth_getTransactionByHash(transactionHash: string): Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">>
  • Returns the information about a transaction requested by transaction hash.

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard

    const tx = await provider.request({ method: "eth_getTransactionByHash", params: [ txHash ] });
    console.log(tx);

    Parameters

    • transactionHash: string

      Hash of a transaction.

    Returns Promise<LegacyTransactionJSON | EIP2930AccessListTransactionJSON | EIP1559FeeMarketTransactionJSON | Transaction<"private">>

    The transaction object or null if no transaction was found.

    • hash: DATA, 32 Bytes - The transaction hash.
    • nonce: QUANTITY - The number of transactions made by the sender prior to this one.
    • blockHash: DATA, 32 Bytes - The hash of the block the transaction is in. null when pending.
    • blockNumber: QUANTITY - The number of the block the transaction is in. null when pending.
    • transactionIndex: QUANTITY - The index position of the transaction in the block.
    • from: DATA, 20 Bytes - The address the transaction is sent from.
    • to: DATA, 20 Bytes - The address the transaction is sent to.
    • value: QUANTITY - The value transferred in wei.
    • gas: QUANTITY - The gas provided by the sender.
    • gasPrice: QUANTITY - The price of gas in wei.
    • input: DATA - The data sent along with the transaction.
    • v: QUANTITY - ECDSA recovery id.
    • r: DATA, 32 Bytes - ECDSA signature r.
    • s: DATA, 32 Bytes - ECDSA signature s.

eth_getTransactionCount

  • eth_getTransactionCount(address: string, blockNumber?: string): Promise<Quantity>
  • Returns the number of transactions sent from an address.

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard

    const txCount = await provider.request({ method: "eth_getTransactionCount", params: [ from, "latest" ] });
    console.log(txCount);

    Parameters

    • address: string

      DATA, 20 Bytes - The address to get number of transactions sent from

    • blockNumber: string = Tag.latest

      Integer block number, or the string "latest", "earliest" or "pending".

    Returns Promise<Quantity>

    Number of transactions sent from this address.

eth_getTransactionReceipt

  • eth_getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>
  • Returns the receipt of a transaction by transaction hash.

    Note: The receipt is not available for pending transactions.

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard

    const txReceipt = await provider.request({ method: "eth_getTransactionReceipt", params: [ txHash ] });
    console.log(txReceipt);

    Parameters

    • transactionHash: string

      Hash of a transaction.

    Returns Promise<TransactionReceipt>

    Returns the receipt of a transaction by transaction hash.

eth_getUncleByBlockHashAndIndex

  • eth_getUncleByBlockHashAndIndex(hash: string, index: string): Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>
  • Returns information about a uncle of a block by hash and uncle index position.

    example
    const blockHash = await provider.send("eth_getBlockByNumber", ["latest"] );
    const block = await provider.send("eth_getUncleByBlockHashAndIndex", [blockHash, "0x0"] );
    console.log(block);

    Parameters

    • hash: string

      Hash of a block.

    • index: string

      The uncle's index position.

    Returns Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>

    A block object or null when no block is found.

    • hash: DATA, 32 Bytes - Hash of the block. null when pending.
    • parentHash: DATA, 32 Bytes - Hash of the parent block.
    • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.
    • miner: DATA, 20 Bytes - Address of the miner.
    • stateRoot: DATA, 32 Bytes - The root of the state trie of the block.
    • transactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block.
    • receiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block.
    • logsBloom: DATA, 256 Bytes - The bloom filter for the logs of the block. null when pending.
    • difficulty: QUANTITY - Integer of the difficulty of this block.
    • number: QUANTITY - The block number. null when pending.
    • gasLimit: QUANTITY - The maximum gas allowed in the block.
    • gasUsed: QUANTITY - Total gas used by all transactions in the block.
    • timestamp: QUANTITY - The unix timestamp for when the block was collated.
    • extraData: DATA - Extra data for the block.
    • mixHash: DATA, 256 Bytes - Hash identifier for the block.
    • nonce: DATA, 8 Bytes - Hash of the generated proof-of-work. null when pending.
    • totalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block.
    • size: QUANTITY - Integer the size of the block in bytes.
    • uncles: Array - Array of uncle hashes.

    **NOTE: **The return does not contain a list of transactions in the uncle block, to get this, make another request to eth_getBlockByHash.

eth_getUncleByBlockNumberAndIndex

  • eth_getUncleByBlockNumberAndIndex(blockNumber: string, uncleIndex: string): Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>
  • Returns information about a uncle of a block by hash and uncle index position.

    example
    const block = await provider.send("eth_getUncleByBlockNumberAndIndex", ["latest", "0x0"] );
    console.log(block);

    Parameters

    • blockNumber: string

      A block number, or the string "earliest", "latest" or "pending".

    • uncleIndex: string

      The uncle's index position.

    Returns Promise<Omit<{ baseFeePerGas?: string; difficulty: string; extraData: string; gasLimit: string; gasUsed: string; hash: string; logsBloom: string; miner: string; mixHash: string; nonce: string; number: string; parentHash: string; receiptsRoot: string; sha3Uncles: string; size: string; stateRoot: string; timestamp: string; totalDifficulty: string; transactions: ({ hash: string; type?: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; gas: string; gasPrice: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { hash: string; type: string; chainId: string; nonce: string; blockHash: string; blockNumber: string; transactionIndex: string; from: string; to: string; value: string; maxPriorityFeePerGas: string; maxFeePerGas: string; gasPrice: string; gas: string; input: string; accessList: { address: string; storageKeys: string[]; }[]; v: string; r: string; s: string; } | { type?: string; from: string; nonce: string; gas: string; to: string; value: string; input: string; v: string; r: string; s: string; gasPrice: string; blockNumber: null; blockHash: null; transactionIndex: null; hash: string; })[]; transactionsRoot: string; uncles: string[] }, "transactions">>

    A block object or null when no block is found.

    • hash: DATA, 32 Bytes - Hash of the block. null when pending.

    • parentHash: DATA, 32 Bytes - Hash of the parent block.

    • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.

    • miner: DATA, 20 Bytes - Address of the miner.

    • stateRoot: DATA, 32 Bytes - The root of the state trie of the block.

    • transactionsRoot: DATA, 32 Bytes - The root of the transaction trie of the block.

    • receiptsRoot: DATA, 32 Bytes - The root of the receipts trie of the block.

    • logsBloom: DATA, 256 Bytes - The bloom filter for the logs of the block. null when pending.

    • difficulty: QUANTITY - Integer of the difficulty of this block.

    • number: QUANTITY - The block number. null when pending.

    • gasLimit: QUANTITY - The maximum gas allowed in the block.

    • gasUsed: QUANTITY - Total gas used by all transactions in the block.

    • timestamp: QUANTITY - The unix timestamp for when the block was collated.

    • extraData: DATA - Extra data for the block.

    • mixHash: DATA, 256 Bytes - Hash identifier for the block.

    • nonce: DATA, 8 Bytes - Hash of the generated proof-of-work. null when pending.

    • totalDifficulty: QUANTITY - Integer of the total difficulty of the chain until this block.

    • size: QUANTITY - Integer the size of the block in bytes.

    • uncles: Array - Array of uncle hashes.

    • **NOTE: **The return does not contain a list of transactions in the uncle block, to get this, make another request to eth_getBlockByHash.

eth_getUncleCountByBlockHash

  • eth_getUncleCountByBlockHash(hash: string): Promise<Quantity>
  • Returns the number of uncles in a block from a block matching the given block hash.

    example
    const blockHash = await provider.send("eth_getBlockByNumber", ["latest"] );
    const uncleCount = await provider.send("eth_getUncleCountByBlockHash", [blockHash] );
    console.log(uncleCount);

    Parameters

    • hash: string

      Hash of a block.

    Returns Promise<Quantity>

    The number of uncles in a block.

eth_getUncleCountByBlockNumber

  • eth_getUncleCountByBlockNumber(blockNumber: string): Promise<Quantity>
  • Returns the number of uncles in a block from a block matching the given block hash.

    example
    const uncleCount = await provider.send("eth_getUncleCountByBlockNumber", ["latest"] );
    console.log(uncleCount);

    Parameters

    • blockNumber: string

      A block number, or the string "earliest", "latest" or "pending".

    Returns Promise<Quantity>

    The number of uncles in a block.

eth_getWork

  • eth_getWork(): Promise<[] | [string, string, string]>
  • Returns: An Array with the following elements 1: DATA, 32 Bytes - current block header pow-hash 2: DATA, 32 Bytes - the seed hash used for the DAG. 3: DATA, 32 Bytes - the boundary condition ("target"), 2^256 / difficulty.

    example
    console.log(await provider.send("eth_getWork", [] ));
    

    Returns Promise<[] | [string, string, string]>

    The hash of the current block, the seedHash, and the boundary condition to be met ("target").

eth_hashrate

  • eth_hashrate(): Promise<Quantity>
  • Returns the number of hashes per second that the node is mining with.

    example
    const hashrate = await provider.request({ method: "eth_hashrate", params: [] });
    console.log(hashrate);

    Returns Promise<Quantity>

    Number of hashes per second.

eth_maxPriorityFeePerGas

  • eth_maxPriorityFeePerGas(): Promise<Quantity>
  • Returns a maxPriorityFeePerGas value suitable for quick transaction inclusion.

    example
    const suggestedTip = await provider.request({ method: "eth_maxPriorityFeePerGas", params: [] });
    console.log(suggestedTip);

    Returns Promise<Quantity>

    The maxPriorityFeePerGas in wei.

eth_mining

  • eth_mining(): Promise<boolean>
  • Returns true if client is actively mining new blocks.

    example
    const isMining = await provider.request({ method: "eth_mining", params: [] });
    console.log(isMining);

    Returns Promise<boolean>

    returns true if the client is mining, otherwise false.

eth_newBlockFilter

  • eth_newBlockFilter(): Promise<Quantity>
  • Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.

    example
    const filterId = await provider.request({ method: "eth_newBlockFilter", params: [] });
    console.log(filterId);

    Returns Promise<Quantity>

    A filter id.

eth_newFilter

  • eth_newFilter(filter?: RangeFilterArgs): Promise<Quantity>
  • Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.

    If the from fromBlock or toBlock option are equal to "latest" the filter continually append logs for whatever block is seen as latest at the time the block was mined, not just for the block that was "latest" when the filter was created.

    A note on specifying topic filters:

    Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:

    • [] “anything”
    • [A] “A in first position (and anything after)”
    • [null, B] “anything in first position AND B in second position (and anything after)”
    • [A, B] “A in first position AND B in second position (and anything after)”
    • [[A, B], [A, B]] “(A OR B) in first position AND (A OR B) in second position (and anything after)”

    Filter options:

    • fromBlock: QUANTITY | TAG (optional) - Integer block number, or the string "latest", "earliest" or "pending".
    • toBlock: QUANTITY | TAG (optional) - Integer block number, or the string "latest", "earliest" or "pending".
    • address: DATA | Array (optional) - Contract address or a list of addresses from which the logs should originate.
    • topics: Array of DATA (optional) - Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
    example
    const filterId = await provider.request({ method: "eth_newFilter", params: [] });
    console.log(filterId);

    Parameters

    • Optional filter: RangeFilterArgs

      The filter options as seen in source.

    Returns Promise<Quantity>

    A filter id.

eth_newPendingTransactionFilter

  • eth_newPendingTransactionFilter(): Promise<Quantity>
  • Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.

    example
    const filterId = await provider.request({ method: "eth_newPendingTransactionFilter", params: [] });
    console.log(filterId);

    Returns Promise<Quantity>

    A filter id.

eth_protocolVersion

  • eth_protocolVersion(): Promise<Data>
  • Returns the current ethereum protocol version.

    example
    const version = await provider.request({ method: "eth_protocolVersion", params: [] });
    console.log(version);

    Returns Promise<Data>

    The current ethereum protocol version.

eth_sendRawTransaction

  • eth_sendRawTransaction(transaction: string): Promise<Data>
  • Creates new message call transaction or a contract creation for signed transactions.

    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    const signedTx = await provider.request({ method: "eth_signTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
    const txHash = await provider.send("eth_sendRawTransaction", [signedTx] );
    console.log(txHash);

    Parameters

    • transaction: string

      The signed transaction data.

    Returns Promise<Data>

    The transaction hash.

eth_sendTransaction

  • eth_sendTransaction(transaction: Transaction): Promise<Data>
  • Creates new message call transaction or a contract creation, if the data field contains code.

    Transaction call object:

    • from: DATA, 20 bytes (optional) - The address the transaction is sent from.
    • to: DATA, 20 bytes - The address the transaction is sent to.
    • gas: QUANTITY (optional) - Integer of the maximum gas allowance for the transaction.
    • gasPrice: QUANTITY (optional) - Integer of the price of gas in wei.
    • value: QUANTITY (optional) - Integer of the value in wei.
    • data: DATA (optional) - Hash of the method signature and the ABI encoded parameters.
    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const txHash = await provider.request({ method: "eth_sendTransaction", params: [{ from, to, gas: "0x5b8d80" }] });
    await provider.once("message"); // Note: `await provider.once` is non-standard
    console.log(txHash);

    Parameters

    • transaction: Transaction

      The transaction call object as seen in source.

    Returns Promise<Data>

    The transaction hash.

eth_sign

  • eth_sign(address: string, message: string): Promise<string>
  • The sign method calculates an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + message.length + message))).

    By adding a prefix to the message makes the calculated signature recognizable as an Ethereum specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim.

    Note the address to sign with must be unlocked.

    example
    const [account] = await provider.request({ method: "eth_accounts", params: [] });
    const msg = "0x307866666666666666666666";
    const signature = await provider.request({ method: "eth_sign", params: [account, msg] });
    console.log(signature);

    Parameters

    • address: string

      Address to sign with.

    • message: string

      Message to sign.

    Returns Promise<string>

    Signature - a hex encoded 129 byte array starting with 0x. It encodes the r, s, and v parameters from appendix F of the yellow paper in big-endian format. Bytes 0...64 contain the r parameter, bytes 64...128 the s parameter, and the last byte the v parameter. Note that the v parameter includes the chain id as specified in EIP-155.

eth_signTransaction

  • eth_signTransaction(transaction: Transaction): Promise<Data>
  • Signs a transaction that can be submitted to the network at a later time using eth_sendRawTransaction.

    Transaction call object:

    • from: DATA, 20 bytes (optional) - The address the transaction is sent from.
    • to: DATA, 20 bytes - The address the transaction is sent to.
    • gas: QUANTITY (optional) - Integer of the maximum gas allowance for the transaction.
    • gasPrice: QUANTITY (optional) - Integer of the price of gas in wei.
    • value: QUANTITY (optional) - Integer of the value in wei.
    • data: DATA (optional) - Hash of the method signature and the ABI encoded parameters.
    example
    const [from, to] = await provider.request({ method: "eth_accounts", params: [] });
    const signedTx = await provider.request({ method: "eth_signTransaction", params: [{ from, to }] });
    console.log(signedTx)

    Parameters

    • transaction: Transaction

      The transaction call object as seen in source.

    Returns Promise<Data>

    The raw, signed transaction.

eth_signTypedData

  • eth_signTypedData(address: string, typedData: TypedMessage<MessageTypes>): Promise<string>
  • Identical to eth_signTypedData_v4.

    eip

    712

    example
    const [account] = await provider.request({ method: "eth_accounts", params: [] });
    const typedData = {
    types: {
    EIP712Domain: [
    { name: 'name', type: 'string' },
    { name: 'version', type: 'string' },
    { name: 'chainId', type: 'uint256' },
    { name: 'verifyingContract', type: 'address' },
    ],
    Person: [
    { name: 'name', type: 'string' },
    { name: 'wallet', type: 'address' }
    ],
    Mail: [
    { name: 'from', type: 'Person' },
    { name: 'to', type: 'Person' },
    { name: 'contents', type: 'string' }
    ],
    },
    primaryType: 'Mail',
    domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
    },
    message: {
    from: {
    name: 'Cow',
    wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
    },
    to: {
    name: 'Bob',
    wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
    },
    contents: 'Hello, Bob!',
    },
    };
    const signature = await provider.request({ method: "eth_signTypedData", params: [account, typedData] });
    console.log(signature);

    Parameters

    • address: string

      Address of the account that will sign the messages.

    • typedData: TypedMessage<MessageTypes>

      Typed structured data to be signed.

    Returns Promise<string>

    Signature. As in eth_sign, it is a hex encoded 129 byte array starting with 0x. It encodes the r, s, and v parameters from appendix F of the yellow paper in big-endian format. Bytes 0...64 contain the r parameter, bytes 64...128 the s parameter, and the last byte the v parameter. Note that the v parameter includes the chain id as specified in EIP-155.

eth_signTypedData_v4

  • eth_signTypedData_v4(address: string, typedData: TypedMessage<MessageTypes>): Promise<string>
  • eip

    712

    example
    const [account] = await provider.request({ method: "eth_accounts", params: [] });
    const typedData = {
    types: {
    EIP712Domain: [
    { name: 'name', type: 'string' },
    { name: 'version', type: 'string' },
    { name: 'chainId', type: 'uint256' },
    { name: 'verifyingContract', type: 'address' },
    ],
    Person: [
    { name: 'name', type: 'string' },
    { name: 'wallet', type: 'address' }
    ],
    Mail: [
    { name: 'from', type: 'Person' },
    { name: 'to', type: 'Person' },
    { name: 'contents', type: 'string' }
    ],
    },
    primaryType: 'Mail',
    domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
    },
    message: {
    from: {
    name: 'Cow',
    wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
    },
    to: {
    name: 'Bob',
    wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
    },
    contents: 'Hello, Bob!',
    },
    };
    const signature = await provider.request({ method: "eth_signTypedData_v4", params: [account, typedData] });
    console.log(signature);

    Parameters

    • address: string

      Address of the account that will sign the messages.

    • typedData: TypedMessage<MessageTypes>

      Typed structured data to be signed.

    Returns Promise<string>

    Signature. As in eth_sign, it is a hex encoded 129 byte array starting with 0x. It encodes the r, s, and v parameters from appendix F of the yellow paper in big-endian format. Bytes 0...64 contain the r parameter, bytes 64...128 the s parameter, and the last byte the v parameter. Note that the v parameter includes the chain id as specified in EIP-155.

eth_submitHashrate

  • eth_submitHashrate(hashRate: string, clientID: string): Promise<boolean>
  • Used for submitting mining hashrate.

    example
    const hashRate = "0x0000000000000000000000000000000000000000000000000000000000000001";
    const clientId = "0xb2222a74119abd18dbcb7d1f661c6578b7bbeb4984c50e66ed538347f606b971";
    const result = await provider.request({ method: "eth_submitHashrate", params: [hashRate, clientId] });
    console.log(result);

    Parameters

    • hashRate: string

      A hexadecimal string representation (32 bytes) of the hash rate.

    • clientID: string

      A random hexadecimal(32 bytes) ID identifying the client.

    Returns Promise<boolean>

    true if submitting went through successfully and false otherwise.

eth_submitWork

  • eth_submitWork(nonce: string, powHash: string, digest: string): Promise<boolean>
  • Used for submitting a proof-of-work solution.

    example
    const nonce = "0xe0df4bd14ab39a71";
    const powHash = "0x0000000000000000000000000000000000000000000000000000000000000001";
    const digest = "0xb2222a74119abd18dbcb7d1f661c6578b7bbeb4984c50e66ed538347f606b971";
    const result = await provider.request({ method: "eth_submitWork", params: [nonce, powHash, digest] });
    console.log(result);

    Parameters

    • nonce: string

      The nonce found (64 bits).

    • powHash: string

      The header's pow-hash (256 bits).

    • digest: string

      The mix digest (256 bits).

    Returns Promise<boolean>

    true if the provided solution is valid, otherwise false.

eth_subscribe

  • eth_subscribe(subscriptionName: SubscriptionName): PromiEvent<Quantity>
  • eth_subscribe(subscriptionName: "logs", options: BaseFilterArgs): PromiEvent<Quantity>
  • Starts a subscription to a particular event. For every event that matches the subscription a JSON-RPC notification with event details and subscription ID will be sent to a client.

    example
    const subscriptionId = await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    console.log(subscriptionId);

    Parameters

    • subscriptionName: SubscriptionName

      Name for the subscription.

    Returns PromiEvent<Quantity>

    A subscription id.

  • Starts a subscription to a particular event. For every event that matches the subscription a JSON-RPC notification with event details and subscription ID will be sent to a client.

    Parameters

    • subscriptionName: "logs"
    • options: BaseFilterArgs

      Filter options:

      • address: either an address or an array of addresses. Only logs that are created from these addresses are returned
      • topics, only logs which match the specified topics

    Returns PromiEvent<Quantity>

    A subscription id.

eth_syncing

  • eth_syncing(): Promise<boolean>
  • Returns an object containing data about the sync status or false when not syncing.

    example
    const result = await provider.request({ method: "eth_syncing", params: [] });
    console.log(result);

    Returns Promise<boolean>

    An object with sync status data or false, when not syncing.

    • startingBlock: {bigint} The block at which the import started (will only be reset, after the sync reached his head).
    • currentBlock: {bigint} The current block, same as eth_blockNumber.
    • highestBlock: {bigint} The estimated highest block.

eth_uninstallFilter

  • eth_uninstallFilter(filterId: string): Promise<boolean>
  • Uninstalls a filter with given id. Should always be called when watch is no longer needed.

    example
    const filterId = await provider.request({ method: "eth_newFilter", params: [] });
    const result = await provider.request({ method: "eth_uninstallFilter", params: [filterId] });
    console.log(result);

    Parameters

    • filterId: string

      The filter id.

    Returns Promise<boolean>

    true if the filter was successfully uninstalled, otherwise false.

eth_unsubscribe

  • eth_unsubscribe(subscriptionId: string): Promise<boolean>
  • Cancel a subscription to a particular event. Returns a boolean indicating if the subscription was successfully cancelled.

    example
    const subscriptionId = await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const result = await provider.request({ method: "eth_unsubscribe", params: [subscriptionId] });
    console.log(result);

    Parameters

    • subscriptionId: string

      The ID of the subscription to unsubscribe to.

    Returns Promise<boolean>

    true if subscription was cancelled successfully, otherwise false.

evm_addAccount

  • evm_addAccount(address: string, passphrase: string): Promise<boolean>
  • Adds any arbitrary account to the personal namespace.

    Note: accounts already known to the personal namespace and accounts returned by eth_accounts cannot be re-added using this method.

    example
    const address = "0x742d35Cc6634C0532925a3b844Bc454e4438f44e";
    const passphrase = "passphrase"
    const result = await provider.send("evm_addAccount", [address, passphrase] );
    console.log(result);

    Parameters

    • address: string

      The address of the account to add to the personal namespace.

    • passphrase: string

      The passphrase used to encrypt the account's private key. NOTE: this passphrase will be needed for all personal namespace calls that require a password.

    Returns Promise<boolean>

    true if the account was successfully added. false if the account is already in the personal namespace.

evm_increaseTime

  • evm_increaseTime(seconds: string | number): Promise<number>
  • Jump forward in time by the given amount of time, in seconds.

    example
    const seconds = 10;
    const timeAdjustment = await provider.send("evm_increaseTime", [seconds] );
    console.log(timeAdjustment);

    Parameters

    • seconds: string | number

      Number of seconds to jump forward in time by. Must be greater than or equal to 0.

    Returns Promise<number>

    Returns the total time adjustment, in seconds.

evm_mine

  • evm_mine(): Promise<"0x0">
  • evm_mine(timestamp: number): Promise<"0x0">
  • evm_mine(options: MineOptions): Promise<"0x0">
  • Force a single block to be mined.

    Mines a block independent of whether or not mining is started or stopped. Will mine an empty block if there are no available transactions to mine.

    example
    console.log("start", await provider.send("eth_blockNumber"));
    await provider.send("evm_mine", [{blocks: 5}] ); // mines 5 blocks
    console.log("end", await provider.send("eth_blockNumber"));

    Returns Promise<"0x0">

    The string "0x0". May return additional meta-data in the future.

  • Parameters

    • timestamp: number

    Returns Promise<"0x0">

  • Parameters

    • options: MineOptions

    Returns Promise<"0x0">

evm_removeAccount

  • evm_removeAccount(address: string, passphrase: string): Promise<boolean>
  • Removes an account from the personal namespace.

    Note: accounts not known to the personal namespace cannot be removed using this method.

    example
    const [address] = await provider.request({ method: "eth_accounts", params: [] });
    const passphrase = "passphrase"
    const result = await provider.send("evm_removeAccount", [address, passphrase] );
    console.log(result);

    Parameters

    • address: string

      The address of the account to remove from the personal namespace.

    • passphrase: string

      The passphrase used to decrypt the account's private key.

    Returns Promise<boolean>

    true if the account was successfully removed. false if the account was not in the personal namespace.

evm_revert

  • evm_revert(snapshotId: string): Promise<boolean>
  • Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. This deletes the given snapshot, as well as any snapshots taken after (e.g.: reverting to id 0x1 will delete snapshots with ids 0x1, 0x2, etc.)

    example
    const [from, to] = await provider.send("eth_accounts");
    const startingBalance = BigInt(await provider.send("eth_getBalance", [from] ));

    // take a snapshot
    const snapshotId = await provider.send("evm_snapshot");

    // send value to another account (over-simplified example)
    await provider.send("eth_subscribe", ["newHeads"] );
    await provider.send("eth_sendTransaction", [{from, to, value: "0xffff"}] );
    await provider.once("message"); // Note: `await provider.once` is non-standard

    // ensure balance has updated
    const newBalance = await provider.send("eth_getBalance", [from] );
    assert(BigInt(newBalance) < startingBalance);

    // revert the snapshot
    const isReverted = await provider.send("evm_revert", [snapshotId] );
    assert(isReverted);
    console.log({isReverted: isReverted});

    // ensure balance has reverted
    const endingBalance = await provider.send("eth_getBalance", [from] );
    const isBalanceReverted = assert.strictEqual(BigInt(endingBalance), startingBalance);
    console.log({isBalanceReverted: isBalanceReverted});

    Parameters

    • snapshotId: string

      The snapshot id to revert.

    Returns Promise<boolean>

    true if a snapshot was reverted, otherwise false.

evm_setAccountBalance

  • evm_setAccountBalance(address: string, balance: string): Promise<boolean>
  • Sets the given account's balance to the specified WEI value. Mines a new block before returning.

    Warning: this will result in an invalid state tree.

    example
    const balance = "0x3e8";
    const [address] = await provider.request({ method: "eth_accounts", params: [] });
    const result = await provider.send("evm_setAccountBalance", [address, balance] );
    console.log(result);

    Parameters

    • address: string

      The account address to update.

    • balance: string

      The balance value, in WEI, to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

evm_setAccountCode

  • evm_setAccountCode(address: string, code: string): Promise<boolean>
  • Sets the given account's code to the specified data. Mines a new block before returning.

    Warning: this will result in an invalid state tree.

    example
    const data = "0xbaddad42";
    const [address] = await provider.request({ method: "eth_accounts", params: [] });
    const result = await provider.send("evm_setAccountCode", [address, data] );
    console.log(result);

    Parameters

    • address: string

      The account address to update.

    • code: string

      The code to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

evm_setAccountNonce

  • evm_setAccountNonce(address: string, nonce: string): Promise<boolean>
  • Sets the given account's nonce to the specified value. Mines a new block before returning.

    Warning: this will result in an invalid state tree.

    example
    const nonce = "0x3e8";
    const [address] = await provider.request({ method: "eth_accounts", params: [] });
    const result = await provider.send("evm_setAccountNonce", [address, nonce] );
    console.log(result);

    Parameters

    • address: string

      The account address to update.

    • nonce: string

      The nonce value to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

evm_setAccountStorageAt

  • evm_setAccountStorageAt(address: string, slot: string, value: string): Promise<boolean>
  • Sets the given account's storage slot to the specified data. Mines a new block before returning.

    Warning: this will result in an invalid state tree.

    example
    const slot = "0x0000000000000000000000000000000000000000000000000000000000000005";
    const data = "0xbaddad42";
    const [address] = await provider.request({ method: "eth_accounts", params: [] });
    const result = await provider.send("evm_setAccountStorageAt", [address, slot, data] );
    console.log(result);

    Parameters

    • address: string

      The account address to update.

    • slot: string

      The storage slot that should be set.

    • value: string

      The value to be set.

    Returns Promise<boolean>

    true if it worked, otherwise false.

evm_setTime

  • evm_setTime(time: string | number | Date): Promise<number>
  • Sets the internal clock time to the given timestamp.

    Warning: This will allow you to move backwards in time, which may cause new blocks to appear to be mined before old blocks. This will result in an invalid state.

    example
    const currentDate = Date.now();
    setTimeout(async () => {
    const time = await provider.send("evm_setTime", [currentDate] );
    console.log(time); // should be about two seconds ago
    }, 1000);

    Parameters

    • time: string | number | Date

      JavaScript timestamp (millisecond precision).

    Returns Promise<number>

    The amount of seconds between the given timestamp and now.

evm_snapshot

  • evm_snapshot(): Promise<Quantity>
  • Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created. A snapshot can only be reverted once. After a successful evm_revert, the same snapshot id cannot be used again. Consider creating a new snapshot after each evm_revert if you need to revert to the same point multiple times.

    example
    const provider = ganache.provider();
    const [from, to] = await provider.send("eth_accounts");
    const startingBalance = BigInt(await provider.send("eth_getBalance", [from] ));

    // take a snapshot
    const snapshotId = await provider.send("evm_snapshot");

    // send value to another account (over-simplified example)
    await provider.send("eth_subscribe", ["newHeads"] );
    await provider.send("eth_sendTransaction", [{from, to, value: "0xffff"}] );
    await provider.once("message"); // Note: `await provider.once` is non-standard

    // ensure balance has updated
    const newBalance = await provider.send("eth_getBalance", [from] );
    assert(BigInt(newBalance) < startingBalance);

    // revert the snapshot
    const isReverted = await provider.send("evm_revert", [snapshotId] );
    assert(isReverted);

    // ensure balance has reverted
    const endingBalance = await provider.send("eth_getBalance", [from] );
    const isBalanceReverted = assert.strictEqual(BigInt(endingBalance), startingBalance);
    console.log({isBalanceReverted: isBalanceReverted});

    Returns Promise<Quantity>

    The hex-encoded identifier for this snapshot.

miner_setEtherbase

  • miner_setEtherbase(address: string): Promise<boolean>
  • Sets the etherbase, where mining rewards will go.

    example
    const [account] = await provider.request({ method: "eth_accounts", params: [] });
    console.log(await provider.send("miner_setEtherbase", [account] ));

    Parameters

    • address: string

      The address where the mining rewards will go.

    Returns Promise<boolean>

    true.

miner_setExtra

  • miner_setExtra(extra: string): Promise<boolean>
  • Set the extraData block header field a miner can include.

    example
    console.log(await provider.send("miner_setExtra", ["0x0"] ));
    

    Parameters

    • extra: string

      The extraData to include.

    Returns Promise<boolean>

    If successfully set returns true, otherwise returns an error.

miner_setGasPrice

  • miner_setGasPrice(number: string): Promise<boolean>
  • Sets the default accepted gas price when mining transactions. Any transactions that don't specify a gas price will use this amount. Transactions that are below this limit are excluded from the mining process.

    example
    console.log(await provider.send("miner_setGasPrice", [300000] ));
    

    Parameters

    • number: string

      Default accepted gas price.

    Returns Promise<boolean>

    true.

miner_start

  • miner_start(threads?: number): Promise<boolean>
  • Resume the CPU mining process with the given number of threads.

    Note: threads is ignored.

    example
    await provider.send("miner_stop");
    // check that eth_mining returns false
    console.log(await provider.send("eth_mining"));
    await provider.send("miner_start");
    // check that eth_mining returns true
    console.log(await provider.send("eth_mining"));

    Parameters

    • threads: number = 1

      Number of threads to resume the CPU mining process with.

    Returns Promise<boolean>

    true.

miner_stop

  • miner_stop(): Promise<boolean>
  • Stop the CPU mining operation.

    example
    // check that eth_mining returns true
    console.log(await provider.send("eth_mining"));
    await provider.send("miner_stop");
    // check that eth_mining returns false
    console.log(await provider.send("eth_mining"));

    Returns Promise<boolean>

    true.

net_listening

  • net_listening(): Promise<boolean>
  • Returns true if client is actively listening for network connections.

    example
    console.log(await provider.send("net_listening"));
    

    Returns Promise<boolean>

    true when listening, otherwise false.

net_peerCount

  • net_peerCount(): Promise<Quantity>
  • Returns number of peers currently connected to the client.

    example
    console.log(await provider.send("net_peerCount"));
    

    Returns Promise<Quantity>

    Number of connected peers.

net_version

  • net_version(): Promise<string>
  • Returns the current network id.

    example
    console.log(await provider.send("net_version"));
    

    Returns Promise<string>

    The current network id. This value should NOT be JSON-RPC Quantity/Data encoded.

personal_importRawKey

  • personal_importRawKey(rawKey: string, passphrase: string): Promise<Address>
  • Imports the given unencrypted private key (hex string) into the key store, encrypting it with the passphrase.

    example
    const rawKey = "0x0123456789012345678901234567890123456789012345678901234567890123";
    const passphrase = "passphrase";

    const address = await provider.send("personal_importRawKey",[rawKey, passphrase] );
    console.log(address);

    Parameters

    • rawKey: string

      The raw, unencrypted private key to import.

    • passphrase: string

      The passphrase to encrypt with.

    Returns Promise<Address>

    Returns the address of the new account.

personal_listAccounts

  • personal_listAccounts(): Promise<string[]>
  • Returns all the Ethereum account addresses of all keys that have been added.

    example
    console.log(await provider.send("personal_listAccounts"));
    

    Returns Promise<string[]>

    The Ethereum account addresses of all keys that have been added.

personal_lockAccount

  • personal_lockAccount(address: string): Promise<boolean>
  • Locks the account. The account can no longer be used to send transactions.

    example
    const [account] = await provider.send("personal_listAccounts");
    const isLocked = await provider.send("personal_lockAccount", [account] );
    console.log(isLocked);

    Parameters

    • address: string

      The account address to be locked.

    Returns Promise<boolean>

    Returns true if the account was locked, otherwise false.

personal_newAccount

  • personal_newAccount(passphrase: string): Promise<Address>
  • Generates a new account with private key. Returns the address of the new account.

    example
    const passphrase = "passphrase";
    const address = await provider.send("personal_newAccount", [passphrase] );
    console.log(address);

    Parameters

    • passphrase: string

      The passphrase to encrypt the private key with.

    Returns Promise<Address>

    The new account's address.

personal_sendTransaction

  • personal_sendTransaction(transaction: Transaction, passphrase: string): Promise<Data>
  • Validate the given passphrase and submit transaction.

    The transaction is the same argument as for eth_sendTransaction and contains the from address. If the passphrase can be used to decrypt the private key belonging to tx.from the transaction is verified, signed and send onto the network. The account is not unlocked globally in the node and cannot be used in other RPC calls.

    Transaction call object:

    • from: DATA, 20 bytes (optional) - The address the transaction is sent from.
    • to: DATA, 20 bytes - The address the transaction is sent to.
    • gas: QUANTITY (optional) - Integer of the maximum gas allowance for the transaction.
    • gasPrice: QUANTITY (optional) - Integer of the price of gas in wei.
    • value: QUANTITY (optional) - Integer of the value in wei.
    • data: DATA (optional) - Hash of the method signature and the ABI encoded parameters.
    example
    const passphrase = "passphrase";
    const newAccount = await provider.send("personal_newAccount", [passphrase] );
    const [to] = await provider.send("personal_listAccounts");

    // use account and passphrase to send the transaction
    const txHash = await provider.send("personal_sendTransaction", [{ from: newAccount, to, gasLimit: "0x5b8d80" }, passphrase] );
    console.log(txHash);

    Parameters

    • transaction: Transaction
    • passphrase: string

      The passphrase to decrpyt the private key belonging to tx.from.

    Returns Promise<Data>

    The transaction hash or if unsuccessful an error.

personal_signTransaction

  • personal_signTransaction(transaction: Transaction, passphrase: string): Promise<Data>
  • Validates the given passphrase and signs a transaction that can be submitted to the network at a later time using eth_sendRawTransaction.

    The transaction is the same argument as for eth_signTransaction and contains the from address. If the passphrase can be used to decrypt the private key belonging to tx.from the transaction is verified and signed. The account is not unlocked globally in the node and cannot be used in other RPC calls.

    Transaction call object:

    • from: DATA, 20 bytes (optional) - The address the transaction is sent from.
    • to: DATA, 20 bytes - The address the transaction is sent to.
    • gas: QUANTITY (optional) - Integer of the maximum gas allowance for the transaction.
    • gasPrice: QUANTITY (optional) - Integer of the price of gas in wei.
    • value: QUANTITY (optional) - Integer of the value in wei.
    • data: DATA (optional) - Hash of the method signature and the ABI encoded parameters.
    example
    const [to] = await provider.request({ method: "eth_accounts", params: [] });
    const passphrase = "passphrase";
    const from = await provider.send("personal_newAccount", [passphrase] );
    await provider.request({ method: "eth_subscribe", params: ["newHeads"] });
    const signedTx = await provider.request({ method: "personal_signTransaction", params: [{ from, to }, passphrase] });
    console.log(signedTx)

    Parameters

    • transaction: Transaction

      The transaction call object as seen in source.

    • passphrase: string

    Returns Promise<Data>

    The raw, signed transaction.

personal_unlockAccount

  • personal_unlockAccount(address: string, passphrase: string, duration?: number): Promise<boolean>
  • Unlocks the account for use.

    The unencrypted key will be held in memory until the unlock duration expires. The unlock duration defaults to 300 seconds. An explicit duration of zero seconds unlocks the key until geth exits.

    The account can be used with eth_sign and eth_sendTransaction while it is unlocked.

    example
    // generate an account
    const passphrase = "passphrase";
    const newAccount = await provider.send("personal_newAccount", [passphrase] );
    const isUnlocked = await provider.send("personal_unlockAccount", [newAccount, passphrase] );
    console.log(isUnlocked);

    Parameters

    • address: string

      20 Bytes - The address of the account to unlock.

    • passphrase: string

      Passphrase to unlock the account.

    • duration: number = 300

      (default: 300) Duration in seconds how long the account should remain unlocked for. Set to 0 to disable automatic locking.

    Returns Promise<boolean>

    true if it worked. Throws an error or returns false if it did not.

rpc_modules

  • rpc_modules(): Promise<{ eth: "1.0"; evm: "1.0"; net: "1.0"; personal: "1.0"; rpc: "1.0"; web3: "1.0" }>
  • Returns object of RPC modules.

    example
    console.log(await provider.send("rpc_modules"));
    

    Returns Promise<{ eth: "1.0"; evm: "1.0"; net: "1.0"; personal: "1.0"; rpc: "1.0"; web3: "1.0" }>

    RPC modules.

shh_addToGroup

  • shh_addToGroup(address: string): Promise<boolean>
  • Adds a whisper identity to the group.

    example
    console.log(await provider.send("shh_addToGroup", ["0x0"] ));
    

    Parameters

    • address: string

      The identity address to add to a group.

    Returns Promise<boolean>

    true if the identity was successfully added to the group, otherwise false.

shh_getFilterChanges

  • shh_getFilterChanges(id: string): Promise<[]>

shh_getMessages

  • shh_getMessages(id: string): Promise<boolean>
  • Get all messages matching a filter. Unlike shh_getFilterChanges this returns all messages.

    example
    console.log(await provider.send("shh_getMessages", ["0x0"] ));
    

    Parameters

    • id: string

      The filter id. Ex: "0x7"

    Returns Promise<boolean>

    See: shh_getFilterChanges.

shh_hasIdentity

  • shh_hasIdentity(address: string): Promise<boolean>
  • Checks if the client hold the private keys for a given identity.

    example
    console.log(await provider.send("shh_hasIdentity", ["0x0"] ));
    

    Parameters

    • address: string

      The identity address to check.

    Returns Promise<boolean>

    Returns true if the client holds the private key for that identity, otherwise false.

shh_newFilter

  • shh_newFilter(to: string, topics: string[]): Promise<boolean>
  • Creates filter to notify, when client receives whisper message matching the filter options.

    example
    console.log(await provider.send("shh_newFilter", ["0x0", []] ));
    

    Parameters

    • to: string

      (optional) Identity of the receiver. When present it will try to decrypt any incoming message if the client holds the private key to this identity.

    • topics: string[]

      Array of topics which the incoming message's topics should match.

    Returns Promise<boolean>

    Returns true if the identity was successfully added to the group, otherwise false.

shh_newGroup

  • shh_newGroup(): Promise<string>

shh_newIdentity

  • shh_newIdentity(): Promise<string>
  • Creates new whisper identity in the client.

    example
    console.log(await provider.send("shh_newIdentity"));
    

    Returns Promise<string>

    • The address of the new identity.

shh_post

  • shh_post(postData: any): Promise<boolean>
  • Creates a whisper message and injects it into the network for distribution.

    example
    console.log(await provider.send("shh_post", [{}] ));
    

    Parameters

    • postData: any

    Returns Promise<boolean>

    Returns true if the message was sent, otherwise false.

shh_uninstallFilter

  • shh_uninstallFilter(id: string): Promise<boolean>
  • Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additionally filters timeout when they aren't requested with shh_getFilterChanges for a period of time.

    example
    console.log(await provider.send("shh_uninstallFilter", ["0x0"] ));
    

    Parameters

    • id: string

      The filter id. Ex: "0x7"

    Returns Promise<boolean>

    true if the filter was successfully uninstalled, otherwise false.

shh_version

  • shh_version(): Promise<string>
  • Returns the current whisper protocol version.

    example
    console.log(await provider.send("shh_version"));
    

    Returns Promise<string>

    The current whisper protocol version.

txpool_content

  • txpool_content(): Promise<Content<"private">>
  • Returns the current content of the transaction pool.

    example
    const [from] = await provider.request({ method: "eth_accounts", params: [] });
    const pendingTx = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", nonce:"0x0" }] });
    const queuedTx = await provider.request({ method: "eth_sendTransaction", params: [{ from, gas: "0x5b8d80", nonce:"0x2" }] });
    const pool = await provider.send("txpool_content");
    console.log(pool);

    Returns Promise<Content<"private">>

    The transactions currently pending or queued in the transaction pool.

web3_clientVersion

  • web3_clientVersion(): Promise<string>
  • Returns the current client version.

    example
    console.log(await provider.send("web3_clientVersion"));
    

    Returns Promise<string>

    The current client version.

web3_sha3

  • web3_sha3(data: string): Promise<Data>
  • Returns Keccak-256 (not the standardized SHA3-256) of the given data.

    example
    const data = "hello trufflers";
    const sha3 = await provider.send("web3_sha3", [data] );
    console.log(sha3);

    Parameters

    • data: string

      the data to convert into a SHA3 hash.

    Returns Promise<Data>

    The SHA3 result of the given string.

Generated using TypeDoc