# IForwarder
The Forwarder Interface
The contracts implementing this interface take a role of authorization, authentication and replay protection
for contracts that choose to trust a Forwarder
, instead of relying on a mechanism built into the Ethereum protocol.
if the Forwarder
contract decides that an incoming ForwardRequest
is valid, it must append 20 bytes that
represent the caller to the data
field of the request and send this new data to the target address (the to
field)
⚠️ Warning ⚠️ The Forwarder can have a full control over a Recipient
contract.
Any vulnerability in a Forwarder
implementation can make all of its Recipient
contracts susceptible!
Recipient contracts should only trust forwarders that passed through security audit,
otherwise they are susceptible to identity theft.
# Functions
# getNonce(address from)
→ uint256
(external)
from: The address of a sender.
# Return values
nonce for this address.
# verify(struct IForwarder.ForwardRequest forwardRequest, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes signature)
(external)
Verify the transaction is valid and can be executed.
Implementations must validate the signature and the nonce of the request are correct.
Does not revert and returns successfully if the input is valid.
Reverts if any validation has failed. For instance, if either signature or nonce are incorrect.
Reverts if domainSeparator
or requestTypeHash
are not registered as well.
# execute(struct IForwarder.ForwardRequest forwardRequest, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes signature)
→ bool success, bytes ret
(external)
Executes a transaction specified by the ForwardRequest
.
The transaction is first verified and then executed.
The success flag and returned bytes array of the CALL
are returned as-is.
This method would revert only in case of a verification error.
All the target errors are reported using the returned success flag and returned bytes array.
forwardRequest: All requested transaction parameters.
domainSeparator: The domain used when signing this request.
requestTypeHash: The request type used when signing this request.
suffixData: The ABI-encoded extension data for the current RequestType
used when signing this request.
signature: The client signature to be validated.
# Return values
The success flag of the underlying CALL
to the target address.
The byte array returned by the underlying CALL
to the target address.
# registerRequestType(string typeName, string typeSuffix)
(external)
Register a new Request typehash.
This is necessary for the Forwarder to be able to verify the signatures conforming to the ERC-712.
typeName: The name of the request type.
typeSuffix: Any extra data after the generic params. Must contain add at least one param. The generic ForwardRequest type is always registered by the constructor.
# registerDomainSeparator(string name, string version)
(external)
Register a new domain separator.
This is necessary for the Forwarder to be able to verify the signatures conforming to the ERC-712.
The domain separator must have the following fields: name
, version
, chainId
, verifyingContract
.
The chainId
is the current network's chainId
, and the verifyingContract
is this Forwarder's address.
This method accepts the domain name and version to create and register the domain separator value.
name: The domain's display name.
version: The domain/protocol version.
# Events
# DomainRegistered(bytes32 domainSeparator, bytes domainValue)
# RequestTypeRegistered(bytes32 typeHash, string typeStr)
# Structs
# ForwardRequest
address from
address to
uint256 value
uint256 gas
uint256 nonce
bytes data
uint256 validUntilTime
← Forwarder IERC20Token →