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

ERC20WrappedxWithAuthorize

isol/contracts/kit/ERC20WrappedxWithAuthorize.sol

Kit The ERC20WrappedxWithAuthorize contract lets you upgrade your existing ERC20 token to support gasless, authorized transfers and burns using EIP-712 signatures. Instantly add meta-transaction and relayer support to your token, enabling flexible, secure, and advanced transfer flows.

Import

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

Usage

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
 
import "isol/contracts/kit/ERC20WrappedxWithAuthorize.sol";
 
contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
	constructor() 
		ERC20WrappedxWithAuthorize(
			0x...YouERC20Address,
            "WERC20xAuth Token", 
            "WAUTH", 
            "WERC20xAuth Token", 
            "1"
		)
	{}
}

Arguments

ParameterTypeDescription
underlyingTokenaddressThe address of the underlying ERC20 token
namestringThe name of your token
symbolstringThe symbol (ticker) of your token
domainNamestringEIP-712 domain name for signature verification
domainVersionstringEIP-712 domain version for signature verification

underlyingToken

  • Type: address

The address of the underlying ERC20 token, e.g., 0x..1234.

contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
	constructor() 
		ERC20WrappedxWithAuthorize(
			0x...YouERC20Address, // Underlying Token (address)
            "WERC20xAuth Token", // Name (string)
            "WAUTH", // Symbol (string)
            "WERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

name

  • Type: string

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

contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
	constructor() 
		ERC20WrappedxWithAuthorize(
			0x...YouERC20Address, // Underlying Token (address)
            "WERC20xAuth Token", // Name (string)
            "WAUTH", // Symbol (string)
            "WERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

symbol

  • Type: string

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

contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
	constructor() 
		ERC20WrappedxWithAuthorize(
			0x...YouERC20Address, // Underlying Token (address)
            "WERC20xAuth Token", // Name (string)
            "WAUTH", // Symbol (string)
            "WERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

domainName

  • Type: string

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

contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
	constructor() 
		ERC20WrappedxWithAuthorize(
			0x...YouERC20Address, // Underlying Token (address)
            "WERC20xAuth Token", // Name (string)
            "WAUTH", // Symbol (string)
            "WERC20xAuth Token", // Domain Name (string)
            "1" // Domain Version (string)
		)
	{}
}

domainVersion

  • Type: string

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

contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
	constructor() 
		ERC20WrappedxWithAuthorize(
			0x...YouERC20Address, // Underlying Token (address)
            "WERC20xAuth Token", // Name (string)
            "WAUTH", // Symbol (string)
            "WERC20xAuth 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
underlying-Get the underlying token address

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
depositForuseraccount (address), value (uint256)Deposit tokens for an account
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
withdrawTouseraccount (address), value (uint256)Withdraw tokens to an account

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 ERC20xTransferWithAuthorize, with additional new features below.

FunctionTypeInteractArgumentsDescription
underlyingread--Check authorization state.
depositForwriteuseraccount (address), value (uint256)Deposit tokens for an account
withdrawTowriteuseraccount (address), value (uint256)Withdraw tokens to an account

References

Source code: ERC20WrappedxWithAuthorize
OpenZeppelin: ERC20, ERC20Burnable, ERC20Wrapper, ReentrancyGuard, Ownable

Examples

Deploy

./MyToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
 
import "isol/contracts/kit/ERC20WrappedxWithAuthorize.sol";
 
contract MyToken is ERC20WrappedxWithAuthorize {
	constructor() 
		ERC20WrappedxWithAuthorize(
			0x...YouERC20Address, // Underlying Token (address)
            "WERC20xAuth Token", // Name (string)
            "WAUTH", // Symbol (string)
            "WERC20xAuth 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 = "WERC20_X_AUTH";
const domainVersion = "VERSION";
const chainId = 11155420; // number
const contract = "WERC20_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);