Skip to main content

getTransactionFromBlock

Callable

  • getTransactionFromBlock<ReturnFormat>(web3Context: Web3Context<EthExecutionAPI, any>, block?: string | number | bigint | ArrayBuffer | Uint8Array, transactionIndex: Numbers, returnFormat: ReturnFormat): Promise<undefined | { accessList: { readonly address?: string | undefined; readonly storageKeys?: string[] | undefined; }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; hash: string; input: string; maxFeePerGas: string; maxPriorityFeePerGas: string; nonce: string; r: string; s: string; to?: null | string; transactionIndex?: string; type: string; value: string; yParity: string } | { accessList: { readonly address?: string | undefined; readonly storageKeys?: string[] | undefined; }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; nonce: string; r: string; s: string; to?: null | string; transactionIndex?: string; type: string; value: string; yParity: string } | { blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; nonce: string; r: string; s: string; to?: null | string; transactionIndex?: string; type: string; v: string; value: string }>

  • Type parameters

    Parameters

    Returns Promise<undefined | { accessList: { readonly address?: string | undefined; readonly storageKeys?: string[] | undefined; }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; hash: string; input: string; maxFeePerGas: string; maxPriorityFeePerGas: string; nonce: string; r: string; s: string; to?: null | string; transactionIndex?: string; type: string; value: string; yParity: string } | { accessList: { readonly address?: string | undefined; readonly storageKeys?: string[] | undefined; }[]; blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; nonce: string; r: string; s: string; to?: null | string; transactionIndex?: string; type: string; value: string; yParity: string } | { blockHash?: string; blockNumber?: string; chainId?: string; data?: string; from: string; gas: string; gasPrice: string; hash: string; input: string; nonce: string; r: string; s: string; to?: null | string; transactionIndex?: string; type: string; v: string; value: string }>

    The desired transaction object.

    web3.eth.getTransactionFromBlock('0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00', 0).then(console.log);
    {
    hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
    type: 0n,
    nonce: 0n,
    blockHash: '0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00',
    blockNumber: 1n,
    transactionIndex: 0n,
    from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
    to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
    value: 1n,
    gas: 90000n,
    gasPrice: 2000000000n,
    input: '0x',
    v: 2709n,
    r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
    s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
    }

    web3.eth.getTransactionFromBlock(
    web3.utils.hexToBytes("0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"),
    0,
    { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
    ).then(console.log);
    {
    hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
    type: 0,
    nonce: 0,
    blockHash: '0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00',
    blockNumber: 1,
    transactionIndex: 0,
    from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
    to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
    value: 1,
    gas: 90000,
    gasPrice: 2000000000,
    input: '0x',
    v: 2709,
    r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
    s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
    }