ERC3009
Inherits: IERC3009, StatefulERC712
Author: M^0 Labs
Inherits from ERC712 and StatefulERC712.
State Variables
TRANSFER_WITH_AUTHORIZATION_TYPEHASH
Returns transferWithAuthorization
typehash.
keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
RECEIVE_WITH_AUTHORIZATION_TYPEHASH
Returns receiveWithAuthorization
typehash.
keccak256("ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
CANCEL_AUTHORIZATION_TYPEHASH
Returns cancelAuthorization
typehash.
keccak256("CancelAuthorization(address authorizer,bytes32 nonce)")
authorizationState
Returns the state of an authorization.
Nonces are randomly generated 32-byte data unique to the authorizer's address
Functions
constructor
Construct the ERC3009 contract.
Parameters
name_
string
The name of the contract.
transferWithAuthorization
Execute a transfer with a signed authorization.
Parameters
from_
address
to_
address
value_
uint256
validAfter_
uint256
validBefore_
uint256
nonce_
bytes32
signature_
bytes
transferWithAuthorization
Execute a transfer with a signed authorization.
Parameters
from_
address
to_
address
value_
uint256
validAfter_
uint256
validBefore_
uint256
nonce_
bytes32
r_
bytes32
vs_
bytes32
transferWithAuthorization
Execute a transfer with a signed authorization.
Parameters
from_
address
to_
address
value_
uint256
validAfter_
uint256
validBefore_
uint256
nonce_
bytes32
v_
uint8
r_
bytes32
s_
bytes32
receiveWithAuthorization
Receive a transfer with a signed authorization from the payer.
This has an additional check to ensure that the payee's address matches the caller of this function to prevent front-running attacks. (See security considerations)
Parameters
from_
address
to_
address
value_
uint256
validAfter_
uint256
validBefore_
uint256
nonce_
bytes32
signature_
bytes
receiveWithAuthorization
Receive a transfer with a signed authorization from the payer.
This has an additional check to ensure that the payee's address matches the caller of this function to prevent front-running attacks. (See security considerations)
Parameters
from_
address
to_
address
value_
uint256
validAfter_
uint256
validBefore_
uint256
nonce_
bytes32
r_
bytes32
vs_
bytes32
receiveWithAuthorization
Receive a transfer with a signed authorization from the payer.
This has an additional check to ensure that the payee's address matches the caller of this function to prevent front-running attacks. (See security considerations)
Parameters
from_
address
to_
address
value_
uint256
validAfter_
uint256
validBefore_
uint256
nonce_
bytes32
v_
uint8
r_
bytes32
s_
bytes32
cancelAuthorization
Attempt to cancel an authorization.
Parameters
authorizer_
address
nonce_
bytes32
signature_
bytes
cancelAuthorization
Attempt to cancel an authorization.
Parameters
authorizer_
address
nonce_
bytes32
r_
bytes32
vs_
bytes32
cancelAuthorization
Attempt to cancel an authorization.
Parameters
authorizer_
address
nonce_
bytes32
v_
uint8
r_
bytes32
s_
bytes32
_transferWithAuthorization
Common transfer function used by transferWithAuthorization
and _receiveWithAuthorization
.
Parameters
from_
address
Payer's address (Authorizer).
to_
address
Payee's address.
value_
uint256
Amount to be transferred.
validAfter_
uint256
The time after which this is valid (unix time).
validBefore_
uint256
The time before which this is valid (unix time).
nonce_
bytes32
Unique nonce.
_receiveWithAuthorization
Common receive function used by receiveWithAuthorization
.
Parameters
from_
address
Payer's address (Authorizer).
to_
address
Payee's address.
value_
uint256
Amount to be transferred.
validAfter_
uint256
The time after which this is valid (unix time).
validBefore_
uint256
The time before which this is valid (unix time).
nonce_
bytes32
Unique nonce.
_cancelAuthorization
Common cancel function used by cancelAuthorization
.
Parameters
authorizer_
address
Authorizer's address.
nonce_
bytes32
Nonce of the authorization.
_transfer
Internal ERC20 transfer function that needs to be implemented by the inheriting contract.
Parameters
sender_
address
The sender's address.
recipient_
address
The recipient's address.
amount_
uint256
The amount to be transferred.
_getTransferWithAuthorizationDigest
Returns the internal EIP-712 digest of a transferWithAuthorization call.
Parameters
from_
address
Payer's address (Authorizer).
to_
address
Payee's address.
value_
uint256
Amount to be transferred.
validAfter_
uint256
The time after which this is valid (unix time).
validBefore_
uint256
The time before which this is valid (unix time).
nonce_
bytes32
Unique nonce.
Returns
<none>
bytes32
The internal EIP-712 digest.
_getReceiveWithAuthorizationDigest
Returns the internal EIP-712 digest of a receiveWithAuthorization call.
Parameters
from_
address
Payer's address (Authorizer).
to_
address
Payee's address.
value_
uint256
Amount to be transferred.
validAfter_
uint256
The time after which this is valid (unix time).
validBefore_
uint256
The time before which this is valid (unix time).
nonce_
bytes32
Unique nonce.
Returns
<none>
bytes32
The internal EIP-712 digest.
_getCancelAuthorizationDigest
Returns the internal EIP-712 digest of a cancelAuthorization call.
Parameters
authorizer_
address
Authorizer's address.
nonce_
bytes32
Nonce of the authorization.
Returns
<none>
bytes32
The internal EIP-712 digest.
_revertIfAuthorizationAlreadyUsed
Reverts if the authorization is already used.
Parameters
authorizer_
address
The authorizer's address.
nonce_
bytes32
The nonce of the authorization.