Meta-transaction
Forwarder
ForwardRequest
struct ForwardRequest {
address from;
address to;
uint256 value;
uint256 gas;
uint256 nonce;
uint256 deadline;
bytes data;
}
_FORWARDREQUEST_TYPEHASH
DeadlineExpired
SignatureDoesNotMatch
constructor
execute
function execute(struct Forwarder.ForwardRequest req, bytes signature) external payable returns (bool, bytes)
Executes a ForwardRequest (meta-tx) if signature is verified, deadline is met and nonce is valid
This implementations allows for out of order execution, by allowing several "timelines" per nonce by splitting the uint256 type space into 128 bit subspaces where each subspace is interpreted as maintaining an ordered timeline. The intent of the design is to allow multiple nonces to be valid at any given time. For a detailed explanation: https://github.com/amxx/permit#out-of-order-execution For an example on how to leverage this functionality, see tests/forwarder/forwarder.test.js Will emit NonceUsed(user, timeline, nonce) for better reporting / UX WARNING: failed transactions do not consume a nonce, unlinke regular ethereum transactions. Please make use of the deadline functionality, and if you want to cancel a request, submit a successful transaction with the same nonce.
Name | Type | Description |
---|---|---|
req | struct Forwarder.ForwardRequest | ForwardRequest to be executed |
signature | bytes | EIP-712 signature of the ForwardRequest |
Name | Type | Description |
---|---|---|
[0] | bool | (success, returnData) of the executed request |
[1] | bytes |
EIP712WithNonce
NonceUsed
InvalidNonce
_nonces
DOMAIN_SEPARATOR
Domain Separator as defined in EIP712
Name | Type | Description |
---|---|---|
[0] | bytes32 | keccak256(typeHash, nameHash, versionHash, block.chainid, address(this)) |
getNonce
Gets nonce for the from address in the "default" timeline
For a detailed explanation: https://github.com/amxx/permit#out-of-order-execution
Name | Type | Description |
---|---|---|
from | address | address |
Name | Type | Description |
---|---|---|
[0] | uint256 | nonce |
getNonce
Gets nonce for the from address in the specified timeline
For a detailed explanation: https://github.com/amxx/permit#out-of-order-execution
Name | Type | Description |
---|---|---|
from | address | address |
timeline | uint256 | where the nonce lives |
Name | Type | Description |
---|---|---|
[0] | uint256 | nonce |
_verifyAndConsumeNonce
Extract timeline from nonce, iterates it to consume it, checks for replay protection.
emits NonceUsed(user, timeline, nonce). WARNING: Failed transactions would not consume a nonce, since the reverted transaction won't be able to save in storage.
Name | Type | Description |
---|---|---|
user | address | address sending the nonce. |
fullNonce | uint256 | nonce and timeline info in uint256 space |