Skip to main content

Overview

ForwardRequest represents an EIP-2771 meta-transaction request for GSN (Gas Station Network) style gasless transactions. A user signs the request off-chain, and a relayer submits it on-chain, paying gas on behalf of the user.

API

from

Creates a ForwardRequest from input parameters.
Parameters:
  • from - Address of the actual signer/sender
  • to - Target contract address
  • value - ETH value to send with the call
  • gas - Gas limit for the inner call
  • nonce - Replay protection nonce
  • data - Calldata to execute on target contract
  • validUntilTime - Unix timestamp after which request is invalid

fromFields

Creates a ForwardRequest from individual field parameters.

structHash

Computes the EIP-712 struct hash for the request.
The struct hash is keccak256(typeHash || encodeData) where encodeData contains all fields ABI-encoded.

hash

Computes the EIP-712 typed data hash for signing.
Returns keccak256("\x19\x01" || domainSeparator || structHash) - the hash to sign.

equals

Checks equality between two ForwardRequests.

isExpired

Checks if the request has expired based on current time.

isValid

Checks if the request is still valid (not expired).

getTypeString

Returns the EIP-712 type string for ForwardRequest.

Types

ForwardRequestType

Constants

FORWARD_REQUEST_TYPEHASH

Pre-computed keccak256 hash of the EIP-712 type string.

Meta-Transaction Flow

1. User Signs Request

User creates and signs a ForwardRequest off-chain:

2. Relayer Submits On-Chain

Relayer receives request + signature and submits to forwarder:

3. Forwarder Executes

Forwarder contract verifies signature and calls target with msg.sender set to original user (via EIP-2771 trusted forwarder pattern).

EIP-2771 Compliance

This implementation follows the EIP-2771 specification for native meta-transactions. Key points:
  • Trusted Forwarder: Target contracts must implement _msgSender() to extract the original sender from calldata
  • Domain Separator: Each forwarder contract has its own EIP-712 domain
  • Replay Protection: Nonce prevents replay attacks; validUntilTime prevents stale requests

See Also