Skip to main content

sendSignedTransaction

Callable


  • Type parameters

    • ReturnFormat: DataFormat
    • ResolveType = { blockHash: ByteTypes[ReturnFormat[bytes]]; blockNumber: NumberTypes[ReturnFormat[number]]; contractAddress?: string; cumulativeGasUsed: NumberTypes[ReturnFormat[number]]; effectiveGasPrice?: NumberTypes[ReturnFormat[number]]; from: string; gasUsed: NumberTypes[ReturnFormat[number]]; logs: { readonly id?: string | undefined; readonly removed?: boolean | undefined; readonly logIndex?: NumberTypes[ReturnFormat["number"]] | undefined; ... 6 more ...; readonly topics?: ByteTypes[ReturnFormat["bytes"]][] | undefined; }[]; logsBloom: ByteTypes[ReturnFormat[bytes]]; root: ByteTypes[ReturnFormat[bytes]]; status: NumberTypes[ReturnFormat[number]]; to: string; transactionHash: ByteTypes[ReturnFormat[bytes]]; transactionIndex: NumberTypes[ReturnFormat[number]]; type?: NumberTypes[ReturnFormat[number]] }

    Parameters

    Returns Web3PromiEvent<ResolveType, SendSignedTransactionEvents<ReturnFormat>>

    If awaited or .thend (i.e. the promise resolves), the transaction hash is returned.

    const signedTransaction = "0xf86580843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a95a03a42d53ca5b71f845e1cd4c65359b05446a85d16881372d3bfaab8980935cb04a0711497bc8dd3b541152e2fed14fe650a647f1f0edab0d386ad9506f0e642410f"

    const transactionHash = await web3.eth.sendSignedTransaction(signedTransaction);
    console.log(transactionHash);
    > 0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700

    web3.eth.sendSignedTransaction(signedTransaction).then(console.log);
    > 0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700

    web3.eth.sendSignedTransaction(signedTransaction).catch(console.log);
    > <Some TransactionError>

    Otherwise, a Web3PromiEvent is returned which has several events than can be listened to using the .on syntax, such as:

    • sending
      web3.eth.sendSignedTransaction(signedTransaction).on('sending', transactionToBeSent => console.log(transactionToBeSent));
      > "0xf86580843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a95a03a42d53ca5b71f845e1cd4c65359b05446a85d16881372d3bfaab8980935cb04a0711497bc8dd3b541152e2fed14fe650a647f1f0edab0d386ad9506f0e642410f"
    • sent
      web3.eth.sendSignedTransaction(signedTransaction).on('sent', sentTransaction => console.log(sentTransaction));
      > "0xf86580843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a95a03a42d53ca5b71f845e1cd4c65359b05446a85d16881372d3bfaab8980935cb04a0711497bc8dd3b541152e2fed14fe650a647f1f0edab0d386ad9506f0e642410f"
    • transactionHash
      web3.eth.sendSignedTransaction(signedTransaction).on('transactionHash', transactionHash => console.log(transactionHash));
      > 0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700
    • receipt
      web3.eth.sendSignedTransaction(signedTransaction).on('receipt', receipt => console.log(receipt));
      > {
      blockHash: '0xff2b1687995d81066361bc6affe4455746120a7d4bb75fc938211a2692a50081',
      blockNumber: 1n,
      cumulativeGasUsed: 21000n,
      effectiveGasPrice: 1000000001n,
      from: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
      gasUsed: 21000n,
      logs: [],
      logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
      status: 1n,
      to: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
      transactionHash: '0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700',
      transactionIndex: 0n,
      type: 0n
      }
    • confirmation
      web3.eth.sendSignedTransaction(signedTransaction).on('confirmation', confirmation => console.log(confirmation));
      > {
      confirmations: 1n,
      receipt: {
      blockHash: '0xff2b1687995d81066361bc6affe4455746120a7d4bb75fc938211a2692a50081',
      blockNumber: 1n,
      cumulativeGasUsed: 21000n,
      effectiveGasPrice: 1000000001n,
      from: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
      gasUsed: 21000n,
      logs: [],
      logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
      status: 1n,
      to: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
      transactionHash: '0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700',
      transactionIndex: 0n,
      type: 0n
      },
      latestBlockHash: '0xff2b1687995d81066361bc6affe4455746120a7d4bb75fc938211a2692a50081'
      }
    • error
      web3.eth.sendSignedTransaction(signedTransaction).on('error', error => console.log(error));
      > <Some TransactionError>