Docs/How it works
Gasless messaging
How a message gets on-chain without you paying gas.
The flow#
- 1
You sign
Your wallet signs an EIP-712ForwardRequestdescribing the exact contract call. - 2
The app relays
The app posts the request and signature to its relayer at/api/relay. - 3
The Paymaster submits
The relayer callsPaymaster.relay(), which runs the request through the Forwarder. - 4
The Forwarder checks
It verifies your signature and nonce, then calls Scarf with your address attached. - 5
Scarf records it
It reads you as the sender (ERC-2771), stores the message and emitsMessageSent.
The signed request#
| Field | Meaning |
|---|---|
from | Your address. |
to | The Scarf contract. |
value | ETH sent with the call (for ETH payments). |
gas | Gas limit: an estimate plus 80,000. |
nonce | Your next Forwarder nonce. A request can only run once. |
data | The encoded call, such as sendMessage(…). |
Because the signature covers every field, a relayer can't change the message, the recipient or the amount, and can't replay it.
Who pays#
The relayer pays the gas, and the Paymaster refunds it a fixed amount per message from its own balance: RELAYER_REIMBURSEMENT_WEI (0.00005 ETH by default), capped by the Paymaster's maxReimbursementPerTx (0.01 ETH by default). Anyone can top up the Paymaster with deposit() or a plain transfer.