Skip to content

The contract is simple and based on the EIP-712 standard which includes a customized transferWithPermit function

License

Notifications You must be signed in to change notification settings

0xMaxMa/digital10k-contracts

Repository files navigation

💸 Digital10K-Contract

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

Implements

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)");

Local Development

Require node version >= 16.20

Local Setup Steps:

  1. git clone https://github.com/0xMaxMa/digital10k-contracts.git
  2. Install dependencies: yarn install
  3. Compile Contracts: yarn compile
  4. Run Tests: yarn test

Deployed Contracts

Sepolia Testnet

Digital10kToken: 0xFF2F0676e588bdCA786eBF25d55362d4488Fad64

About

The contract is simple and based on the EIP-712 standard which includes a customized transferWithPermit function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published