Usage
Both open and permissioned trusted forwarders are designed to work with any smart contract that implements TrustedForwarderERC2771Context to create permissioned forwarding channels by routing user calls through the trusted forwarder. Trusted forwarder will ALWAYS append the caller of the trusted forwarder to the end of the calldata sent to the target address and forward the entire msg.value amount to the target.
Note: Trusted Forwarders do not have a fallback or receive function so they CANNOT receive payments from other contracts to refund excess payment amounts. Contracts that utilize a trusted forwarder should issue refunds directly to the appended caller address as native or wrapped tokens.
Open Trusted Forwarder
Steps to execute a call through an open trusted forwarder:
- Determine the target contract address for the call.
- Determine the calldata for the transaction being sent to the target including the 4-byte function selector.
- Call the trusted forwarder
forwardCallwith thetarget,message, and value to send.
function forwardCall(
address target,
bytes calldata message
) external payable returns (bytes memory returnData);
Permissioned Trusted Forwarder
Steps to execute a call through an open trusted forwarder:
- Determine the target contract address for the call.
- Determine the calldata for the transaction being sent to the target including the 4-byte function selector.
- Sign the message using the private key for the signer account that is set for the trusted forwarder.
- The signature will be for an EIP712 structured message using:
- The domain separator returned by the
domainSeparatorV4view function - with
- The message data being an AppSigner message defined here.
- The domain separator returned by the
- The signature will be for an EIP712 structured message using:
- Call the trusted forwarder
forwardCallwith thetarget,message,signatureand value to send.
function forwardCall(
address target,
bytes calldata message,
SignatureECDSA calldata signature
) external payable returns (bytes memory returnData);
AppSigner Type Hash
AppSigner(bytes32 messageHash,address target,address sender)
