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.from- Address of the actual signer/senderto- Target contract addressvalue- ETH value to send with the callgas- Gas limit for the inner callnonce- Replay protection noncedata- Calldata to execute on target contractvalidUntilTime- 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.keccak256(typeHash || encodeData) where encodeData contains all fields ABI-encoded.
hash
Computes the EIP-712 typed data hash for signing.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 withmsg.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;
validUntilTimeprevents stale requests
See Also
- Domain - EIP-712 domain separator
- Signature - ECDSA signing
- Keccak256 - Hash functions
- EIP-2771 - Native meta-transactions specification
- GSN Documentation - Gas Station Network

