Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

ERC20xTransferWithAuthorize

isol/contracts/kit/ERC20xTransferWithAuthorize.sol

Kit The ERC20xTransferWithAuthorize is an advanced ERC20 extension that enables fast, secure, and flexible token transfers and burns using off-chain signatures (EIP-712). It supports meta-transactions and relayer flows, allowing gasless transfers and advanced authorization scenarios.

Import

import "isol/contracts/kit/ERC20xTransferWithAuthorize.sol";

Usage

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
 
import "isol/contracts/kit/ERC20xTransferWithAuthorize.sol";
 
contract ERC20xAuth is ERC20xTransferWithAuthorize {
	constructor() 
		ERC20xTransferWithAuthorize(
			"ERC20xAuth Token",
			"AUTH",
			1000000,
            "ERC20xAuth Token",
            "1"
		)
	{}
}

Arguments

ParameterTypeDescription
namestringThe name of your token
symbolstringThe symbol (ticker) of your token
initialSupplyuint256The initial supply (whole number, no decimals needed)
domainNamestringEIP-712 domain name for signature verification
domainVersionstringEIP-712 domain version for signature verification

name

  • Type: string

The name of your ERC20 token, e.g., "MyToken".

contract ERC20xAuth is ERC20xTransferWithAuthorize {
	constructor() 
		ERC20xTransferWithAuthorize(
			"ERC20xAuth Token", // Name (string)
			"AUTH", // Symbol (string)
			1000000, // Initial Supply (number: uint256)
            "ERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

symbol

  • Type: string

The symbol (ticker) of your ERC20 token, e.g., "MTK".

contract ERC20xAuth is ERC20xTransferWithAuthorize {
	constructor() 
		ERC20xTransferWithAuthorize(
			"ERC20xAuth Token", // Name (string)
			"AUTH", // Symbol (string)
			1000000, // Initial Supply (number: uint256)
            "ERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

initialSupply

  • Type: uint256 (number || bigint)

The initial supply of your ERC20 token, specified as a whole number. This amount will be minted to the deployer's address upon deployment.

contract ERC20xAuth is ERC20xTransferWithAuthorize {
	constructor() 
		ERC20xTransferWithAuthorize(
			"ERC20xAuth Token", // Name (string)
			"AUTH", // Symbol (string)
			1000000, // Initial Supply (number: uint256)
            "ERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

domainName

  • Type: string

The EIP-712 domain name used for signature verification, e.g., "MyToken".

contract ERC20xAuth is ERC20xTransferWithAuthorize {
	constructor() 
		ERC20xTransferWithAuthorize(
			"ERC20xAuth Token", // Name (string)
			"AUTH", // Symbol (string)
			1000000, // Initial Supply (number: uint256)
            "ERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

domainVersion

  • Type: string

The EIP-712 domain version used for signature verification, e.g., "1".

contract ERC20xAuth is ERC20xTransferWithAuthorize {
	constructor() 
		ERC20xTransferWithAuthorize(
			"ERC20xAuth Token", // Name (string)
			"AUTH", // Symbol (string)
			1000000, // Initial Supply (number: uint256)
            "ERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

Functions

Read

FunctionArgumentsDescription
BURN_TYPEHASH-Check the typehash used for burn authorization
TRANSFER_TYPEHASH-Check the typehash used for transfer authorization
allowanceowner (address), spender (address)Check approved amount for spender
authorizeStateauthorizer (address), nonce (bytes32)Check authorization state
balanceOfaccount (address)Get token balance of an address
decimals-Get number of decimals used by the token
eip712Domain-Check the EIP-712 domain used for signature verification
name-Get the name of the token
owner-Get the owner of the token
symbol-Get the symbol of the token
totalSupply-Get the total supply of the token

Write

FunctionInteractArgumentsDescription
approveuserspender (address), value (uint256)Allow spender to use your tokens
burnuservalue (uint256)Burn a specific amount of your tokens
burnFromuseraccount (address), value (uint256)Burn a specific amount of your tokens from an account
burnWithAuthorizeuserfrom (address), value (uint256), createTime (uint256), expireTime (uint256), nonce (bytes32), auth (bytes)Burn tokens with authorization
renounceOwnershipowner-Renounce ownership of the token
transferuserto (address), value (uint256)Send tokens to another address
transferFromuserfrom (address), to (address), value (uint256)Move tokens using allowance
transferOwnershipownernewOwner (address)Transfer ownership of the token
transferWithAuthorizeuserfrom (address), to (address), value (uint256), createTime (uint256), expireTime (uint256), nonce (bytes32), auth (bytes)Transfer tokens with authorization

Events

Logs
Transfer(address indexed from, address indexed to, uint256 value)
Approval(address indexed owner, address indexed spender, uint256 value)
OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
BurnWithAuthorize(address sender, address from, uint256 value, uint256 createTime, uint256 expireTime, bytes32 nonce, bytes auth)
TransferWithAuthorize(address sender, address from, address to, uint256 value, uint256 createTime, uint256 expireTime, bytes32 nonce, bytes auth)

Features

Functions are inherited from KitxERC20, with additional new features below.

FunctionTypeInteractArgumentsDescription
BURN_TYPEHASHread--Check the typehash used for burn authorization
TRANSFER_TYPEHASHread--Check the typehash used for transfer authorization
authorizeStateread-authorizer (address), nonce (bytes32)Check authorization state
eip712Domainread--Check the EIP-712 domain used for signature verification
burnWithAuthorizewriteuserfrom (address), value (uint256), createTime (uint256), expireTime (uint256), nonce (bytes32), auth (bytes)Burn tokens with authorization
transferWithAuthorizewriteuserfrom (address), to (address), value (uint256), createTime (uint256), expireTime (uint256), nonce (bytes32), auth (bytes)Transfer tokens with authorization

References

Source code: ERC20xTransferWithAuthorize
OpenZeppelin: ERC20, ERC20Burnable, ReentrancyGuard, Ownable

Examples

Deploy

./MyToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
 
import "isol/contracts/kit/ERC20xTransferWithAuthorize.sol";
 
contract MyToken is ERC20xTransferWithAuthorize {
	constructor() 
		ERC20xTransferWithAuthorize(
			"ERC20xAuth Token", // Name (string)
			"AUTH", // Symbol (string)
			1000000, // Initial Supply (number: uint256)
            "ERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

Interact

./interact.ts
import { daccSignTypedData } from "dacc-js";
import { createWalletClient, http } from 'viem';
import { parseAbi, toHex } from "viem";
import { privateKeyToAccount } from 'viem/accounts';
import { optimismSepolia } from "viem/chains";
 
// ==========================================
// CONFIG FOR SIGNING
// ==========================================
const domainName = "ERC20_X_AUTH";
const domainVersion = "VERSION";
const chainId = 11155420; // number
const contract = "ERC20_X_AUTH...CONTRACT_ADDRESS";
const walletAddress = "FROM...WALLET_ADDRESS";
const toAddress = "TO...WALLET_ADDRESS";
const amount = 1000000000000000000n; // decimal
 
const nonce = crypto.getRandomValues(new Uint8Array(32)); // bytes32
const now = Math.floor(Date.now() / 1000);
const createTime = now - 60;
const expireTime = now + 3600;
 
const daccID = "DACC_PUBLIC_KEY";
const daccPassword = "DACC_PASSWORD_SECRETKEY";
 
const sponsorPrivateKey = "0X...PRIVEATE_KEY";
 
// ==========================================
// SIGNING WITH DACC-JS
// ==========================================
const signed = await daccSignTypedData({
  daccPublickey: daccID,
  passwordSecretkey: daccPassword,
  network: optimismSepolia,
  domain: {
    name: domainName,
    version: domainVersion,
    chainId: chainId,
    verifyingContract: contract
  },
  types: {
    TransferWithAuthorize: [
        { name: "from", type: "address" },
        { name: "to", type: "address" },
        { name: "value", type: "uint256" },
        { name: "createTime", type: "uint256" },
        { name: "expireTime", type: "uint256" },
        { name: "nonce", type: "bytes32" }
    ]
  },
  primaryType: "TransferWithAuthorize",
  message: {
    from: walletAddress,
    to: toAddress,
    value: amount,
    createTime,
    expireTime,
    nonce: toHex(nonce)
  }
});
// console.log('Signed Data:', signed);
 
// ==========================================
// SEND TRANSACTION WITH VIEM
// ==========================================
const walletClient = createWalletClient({
  account: privateKeyToAccount(sponsorPrivateKey as `0x${string}`),
  chain: optimismSepolia,
  transport: http(),
});
 
const abiContract = parseAbi([
  'function transferWithAuthorize(address from, address to, uint256 value, uint256 createTime, uint256 expireTime, bytes32 nonce, bytes calldata auth)',
]);
 
const tx = await walletClient.writeContract({
    address: contract as `0x${string}`,
    abi: abiContract,
    functionName: "transferWithAuthorize",
    args: [
        walletAddress as `0x${string}`,
        toAddress as `0x${string}`,
        BigInt(amount),
        BigInt(createTime),
        BigInt(expireTime),
        toHex(nonce),
        signed.signature
    ],
});
console.log('Transaction Hash:', tx);