The contract is simple and based on the EIP-712 standard which includes a customized transferWithPermit function. That enables users to perform gasless transfers by utilizing a signed permit signature. The transaction is then executed by a Relayer to transfer the token from the owner to the receiver.
Read more EIP-712: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md
Added transferWithPermit
function.
function transferWithPermit(
address owner,
address receiver,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external {
permit(owner, receiver, value, deadline, v, r, s);
}
On abstract ERC20Permit
, the permit
function changes _approve
to _transfer
to reduce steps to directly transfer.
function permit(
address owner,
address receiver,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
...
// change _approve to _transfer to direct transfer to receiver
_transfer(owner, receiver, value);
}
Use PERMIT_TYPEHASH with:
bytes32 private constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address receiver,uint256 value,uint256 nonce,uint256 deadline)");
Require node version >= 16.20
Local Setup Steps:
- git clone https://github.com/0xMaxMa/digital10k-contracts.git
- Install dependencies:
yarn install
- Compile Contracts:
yarn compile
- Run Tests:
yarn test
Digital10kToken: 0xFF2F0676e588bdCA786eBF25d55362d4488Fad64