Transaction

export class Transaction {
constructor(
    public hash: Bytes,
    public index: BigInt,
    public from: Address,
    public to: Address | null,
    public value: BigInt,
    public gasLimit: BigInt,
    public gasPrice: BigInt,
    public input: Bytes,
    public nonce: BigInt,
) {}
}

Fields and Use Cases

hash

  • Description: The unique identifier (hash) of the transaction.
  • Use Case: Links the transaction to its associated logs, events, and block, enabling tracking and querying of specific transactions.

index

  • Description: The index of the transaction within the block.
  • Use Case: Useful for chronological ordering of transactions within a block and creating unique composite IDs when combined with block number.

from

  • Description: The address of the EOA (Externally Owned Account) that signed and sent the transaction.
  • Use Case: Can be used to create user/account entities, track address-specific activity, and filter transactions by sender in your subgraph mappings.

to

  • Description: the address of the contract if it was a transaction executed on the contract:
    • For regular transactions: The address of the contract where the transaction is being executed
    • For contract creation transactions: Null/undefined
  • Use Case:
    • Useful for filtering contract interactions and tracking contract deployments (when null)
    • Can be compared with event.address to determine:
      • If matching: The transaction is executing on the same contract as the datasource
      • If different: The transaction is executing on another contract that triggered an event on the datasource contract
    • Enables tracking cross-contract interactions and call patterns

value

  • Description: The amount of native cryptocurrency (in wei) transferred with the transaction.
  • Use Case: Can be used to aggregate transfer volumes, track significant transfers, or filter high-value transactions in your subgraph.

gasLimit

  • Description: The maximum number of gas units the transaction is allowed to consume.
  • Use Case: Can be used to analyze transaction complexity, track gas usage patterns, or filter complex transactions in your subgraph.

gasPrice

  • Description: The price (in wei) the sender is willing to pay per unit of gas.
  • Use Case: Useful for calculating transaction costs, analyzing network congestion periods, or filtering high-priority transactions in your mappings.

input

  • Description: The optional input data sent with the transaction, usually used to interact with other smart contracts.
  • Use Case: Can be used to identify specific function calls, decode transaction parameters, or filter transactions by interaction type in your subgraph handlers.

nonce

  • Description: A counter value that represents the number of transactions sent from the sender’s address. Each new transaction from an address must use a nonce value exactly one higher than the previous transaction. The first transaction from an address uses nonce 0.
  • Use Cases:
    • Prevents transaction replay attacks
    • Ensures transactions are processed in the correct order
    • Useful for tracking account activity frequency
    • Can be used to identify the first/latest transaction from an address
    • Helps in monitoring transaction sequence gaps or failed transactions