Class EthereumTransactionData

java.lang.Object
com.hedera.hashgraph.sdk.EthereumTransactionData
Direct Known Subclasses:
EthereumTransactionDataEip1559, EthereumTransactionDataEip2930, EthereumTransactionDataLegacy

public abstract class EthereumTransactionData extends Object
This class represents the data of an Ethereum transaction.

It may be of subclass EthereumTransactionDataLegacy, EthereumTransactionDataEip2930 or EthereumTransactionDataEip1559.

  • Field Details

    • callData

      public byte[] callData
      The raw call data.
  • Constructor Details

    • EthereumTransactionData

      EthereumTransactionData(byte[] callData)
  • Method Details

    • fromBytes

      static EthereumTransactionData fromBytes(byte[] bytes)
    • toBytes

      public abstract byte[] toBytes()
      Serialize the ethereum transaction data into bytes using RLP
      Returns:
      the serialized transaction as a byte array
    • sign

      public abstract byte[] sign(PrivateKey privateKey)
      Sign this transaction body with the given ECDSA private key, populating the signature fields (r, s and the recovery id / v), and return the resulting signed RLP encoding.
      Parameters:
      privateKey - the ECDSA secp256k1 key to sign with
      Returns:
      the signed RLP-encoded transaction
    • toString

      public abstract String toString()
      Serialize the ethereum transaction data into a string
      Overrides:
      toString in class Object
      Returns:
      the serialized transaction as a string
    • signTypedTransaction

      static EthereumTransactionData.SignatureData signTypedTransaction(byte[] unsignedListRlp, int typePrefix, PrivateKey privateKey)
      Sign a typed (non-legacy) Ethereum transaction. The message that is signed is the type prefix byte concatenated with the RLP-encoded unsigned payload list. PrivateKeyECDSA.sign(byte[]) applies keccak256 internally, so the raw message is passed without pre-hashing.
      Parameters:
      unsignedListRlp - the RLP encoding of the unsigned payload list (without the type prefix)
      typePrefix - the EIP transaction type prefix byte
      privateKey - the ECDSA key
      Returns:
      the r/s/recoveryId signature components
    • signMessage

      static EthereumTransactionData.SignatureData signMessage(byte[] message, PrivateKey privateKey)
      Sign a raw message (already keccak256-able) with an ECDSA key and extract the r/s/recoveryId components.
      Parameters:
      message - the message to sign
      privateKey - the ECDSA key
      Returns:
      the r/s/recoveryId signature components
    • ethereumBodyIsSigned

      static boolean ethereumBodyIsSigned(EthereumTransactionData body)
      Parameters:
      body - an ethereum transaction body
      Returns:
      whether the body carries a non-empty signature (both r and s present)