# Forwarder

The Forwarder Implementation

This implementation of the IForwarder interface uses ERC-712 signatures and stored nonces for verification.

# Functions

# receive()

(external)


# getNonce(address from)

→ uint256 (public)

from: The address of a sender.

# Return values

nonce for this address.


# supportsInterface(bytes4 interfaceId)

→ bool (public)

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.


# verify(struct IForwarder.ForwardRequest req, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes sig)

(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 req, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes sig)

→ 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.


# _verifyNonce(struct IForwarder.ForwardRequest req)

(internal)


# _verifyAndUpdateNonce(struct IForwarder.ForwardRequest req)

(internal)


# 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.


# registerRequestTypeInternal(string requestType)

(internal)


# _verifySig(struct IForwarder.ForwardRequest req, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes sig)

(internal)


# _getEncoded(struct IForwarder.ForwardRequest req, bytes32 requestTypeHash, bytes suffixData)

→ bytes (public)

Creates a byte array that is a valid ABI encoding of a request of a RequestType type. See execute().