# isol
## Concept \[Concept design for isol]
### Overview

A dedicated interface layer that defines standards and structural patterns for smart contracts written in Solidity.
It is developed based on OpenZeppelin standards to ensure security, reliability, and compatibility. This architecture presents a structured and scalable approach to building smart contracts. It follows a layered design that starts from standards and core components, then extends functionality through kits and flexible modular components.
The goal of this architecture is to:
* Provide a simple, fast, and highly usable development experience
* Encourage concise, clean code in just a few lines
* Enable easy customization and expansion
* Ensure security and reliability (OpenZeppelin standards)
### Base
The fundamental contract layer used as the foundation for developing other smart contracts.
It provides the essential core functionalities required to build and operate smart contracts.
* Core smart contract structures
* Fundamental logic
* Essential building blocks
### Kit
A collection of ready-to-use extensions that add new features and enhanced capabilities to Base contracts.
It helps speed up development while reducing complexity.
* Ready-to-use features
* Pre-built enhancements
* Extensions that plug directly into Base contracts
* Faster development
* Built-in functionality
* Less boilerplate
### Modular
A modular extension layer designed for building highly flexible and customizable smart contracts.
Developers can freely select, combine, or integrate different modules depending on their specific needs.
* Highly configurable extensions
* Add or remove features as needed
* Suitable for advanced or specialized smart contracts
## Concept \[Concept design for isol]
### Overview

A dedicated interface layer that defines standards and structural patterns for smart contracts written in Solidity.
It is developed based on OpenZeppelin standards to ensure security, reliability, and compatibility. This architecture presents a structured and scalable approach to building smart contracts. It follows a layered design that starts from standards and core components, then extends functionality through kits and flexible modular components.
The goal of this architecture is to:
* Provide a simple, fast, and highly usable development experience
* Encourage concise, clean code in just a few lines
* Enable easy customization and expansion
* Ensure security and reliability (OpenZeppelin standards)
### Base
The fundamental contract layer used as the foundation for developing other smart contracts.
It provides the essential core functionalities required to build and operate smart contracts.
* Core smart contract structures
* Fundamental logic
* Essential building blocks
### Kit
A collection of ready-to-use extensions that add new features and enhanced capabilities to Base contracts.
It helps speed up development while reducing complexity.
* Ready-to-use features
* Pre-built enhancements
* Extensions that plug directly into Base contracts
* Faster development
* Built-in functionality
* Less boilerplate
### Modular
A modular extension layer designed for building highly flexible and customizable smart contracts.
Developers can freely select, combine, or integrate different modules depending on their specific needs.
* Highly configurable extensions
* Add or remove features as needed
* Suitable for advanced or specialized smart contracts
## Getting started \[Get up and running in under a minute]
### Overview
isol
Interface SmartContract Solidity
**isol** is a library for A modern smart contract toolkit, fast to start, designed for simple and secure with **OpenZeppelin** standards. Built for easy use and **future trends**.
### Installation
install `isol` as a dependency in project.
:::code-group
```bash [npm]
npm i isol
```
```bash [bun]
bun add isol
```
```bash [yarn]
yarn add isol
```
```bash [pnpm]
pnpm add isol
```
:::
### Quick Start
::::steps
#### Install
First, we will install `isol` as a dependency in our project.
:::code-group
```bash [npm]
npm i isol
```
```bash [bun]
bun add isol
```
```bash [yarn]
yarn add isol
```
```bash [pnpm]
pnpm add isol
```
:::
#### Build
Create a script file your project.
:::note
We recommend the following tools for creating and deploying smart contracts
:::
* [Foundry](https://getfoundry.sh/) - Fast, portable, and modular toolkit for Ethereum development.
* [Remix](https://remix.ethereum.org/) - Powerful web IDE for Solidity smart contract development.
* [Hardhat](https://hardhat.org/) - Flexible environment for compiling, deploying, testing, and debugging.
#### Run
Create a script file your deploy.
```ts [./Kit.sol]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "isol/contracts/kit/KitxERC20.sol";
contract Kit is KitxERC20 {
constructor()
KitxERC20(
"Kit Token", // Name (string)
"KIT", // Symbol (string)
1000000 // Initial Supply (number: uint256)
)
{}
}
```
::::
### Donate
Support core development team and help to the project growth.
```bash [EVM Compatible]
0x6A74308F267c07556ED170025AE2D1753F747E20
```
## ERC20xTransferWithAuthorize \[isol/contracts/modular/ERC20xTransferWithAuthorize.sol]
**Modular** The `ERC20xTransferWithAuthorize` is an ERC20 extension for modular, off-chain authorized transfers and burns using EIP-712 signatures. It enables meta-transactions, relayer support, and gasless transfers by allowing anyone to submit signed authorizations for transfers or burns. Designed for flexible integration with other contracts or features.
### Import
```solidity
import "isol/contracts/modular/ERC20xTransferWithAuthorize.sol";
```
### Usage
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "isol/contracts/kit/KitxERC20.sol";
import "isol/contracts/modular/ERC20xTransferWithAuthorize.sol";
contract ERC20xAuth is KitxERC20, ERC20xTransferWithAuthorize {
constructor()
KitxERC20("MyToken", "MTK", 1000000)
ERC20xTransferWithAuthorize(
"MyToken",
"1"
)
{}
}
```
### Arguments
| Parameter | Type | Description |
| :-------------- | :------- | :------------------------------------------------ |
| `domainName` | `string` | EIP-712 domain name for signature verification |
| `domainVersion` | `string` | EIP-712 domain version for signature verification |
#### domainName
* **Type:** `string`
The EIP-712 domain name used for signature verification, e.g., "MyToken".
```ts
contract ERC20xAuth is ERC20xTransferWithAuthorize {
constructor()
ERC20xTransferWithAuthorize(
"ERC20xAuth Token", // Name (string)
"AUTH", // Symbol (string)
1000000, // Initial Supply (number: uint256)
"ERC20xAuth Token", // [!code focus] Domain Name (string)
"1" // Domain Version (string)
)
{}
}
```
#### domainVersion
* **Type:** `string`
The EIP-712 domain version used for signature verification, e.g., "1".
```ts
contract ERC20xAuth is ERC20xTransferWithAuthorize {
constructor()
ERC20xTransferWithAuthorize(
"ERC20xAuth Token", // Name (string)
"AUTH", // Symbol (string)
1000000, // Initial Supply (number: uint256)
"ERC20xAuth Token", // Domain Name (string)
"1" // [!code focus] Domain Version (string)
)
{}
}
```
### Functions
#### Read
| Function | Arguments | Description |
| :------------------ | :---------------------------------------- | :------------------------------------------------------- |
| `BURN_TYPEHASH` | - | Check the typehash used for burn authorization |
| `TRANSFER_TYPEHASH` | - | Check the typehash used for transfer authorization |
| `allowance` | owner (`address`), spender (`address`) | Check approved amount for spender |
| `authorizeState` | authorizer (`address`), nonce (`bytes32`) | Check authorization state |
| `balanceOf` | account (`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 |
| `symbol` | - | Get the symbol of the token |
| `totalSupply` | - | Get the total supply of the token |
#### Write
| Function | Interact | Arguments | Description |
| :---------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------- |
| `approve` | user | spender (`address`), value (`uint256`) | Allow spender to use your tokens |
| `burnWithAuthorize` | user | from (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Burn tokens with authorization |
| `transfer` | user | to (`address`), value (`uint256`) | Send tokens to another address |
| `transferFrom` | user | from (`address`), to (`address`), value (`uint256`) | Move tokens using allowance |
| `transferWithAuthorize` | user | from (`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) |
| `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 [BasexERC20](../base/BasexERC20.mdx), with additional new features below.
| Function | Type | Interact | Arguments | Description |
| :---------------------- | :---- | :------- | :------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------- |
| `BURN_TYPEHASH` | read | - | - | Check the typehash used for burn authorization |
| `TRANSFER_TYPEHASH` | read | - | - | Check the typehash used for transfer authorization |
| `authorizeState` | read | - | authorizer (`address`), nonce (`bytes32`) | Check authorization state |
| `eip712Domain` | read | - | - | Check the EIP-712 domain used for signature verification |
| `burnWithAuthorize` | write | user | from (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Burn tokens with authorization |
| `transferWithAuthorize` | write | user | from (`address`), to (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Transfer tokens with authorization |
### References
Source code: [ERC20xTransferWithAuthorize](./)
OpenZeppelin: [ERC20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20), [ReentrancyGuard](https://docs.openzeppelin.com/contracts/5.x/api/utils#reentrancyguard)
### Examples
#### Deploy
```ts [./MyToken.sol]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "isol/contracts/modular/ERC20xTransferWithAuthorize.sol"; // Add modular ERC20xTransferWithAuthorize for advanced transfer with authorization
import "isol/contracts/kit/KitxERC20.sol"; // Add kit KitxERC20 for base ERC20 functionalities
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol"; // Sample additional custom feature
contract MyToken is ERC20xTransferWithAuthorize, KitxERC20, ERC20Pausable { // initialize ERC20xTransferWithAuthorize
constructor()
KitxERC20("MyToken", "MTK", 1000000)
ERC20xTransferWithAuthorize( // use ERC20xTransferWithAuthorize constructor
"MyToken", // Domain Name (string)
"1" // Domain Version (string)
)
{}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function _update(address from, address to, uint256 value)
internal
override(ERC20, ERC20Pausable)
{
super._update(from, to, value);
}
}
```
#### Interact
:::note
Recommend [dacc-js](https://dacc-js.thefactlab.org/functions/dacc-signature/sign-typed-data) an easy-to-use library for interactions, designed to scale your services from Web2 to Web3.
:::
:::warning
Please ensure that you have sufficient token balance and gas fees in your wallet before performing token transfers.
:::
```ts [./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);
```
## 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.
:::note
This contract wrap an existing ERC20 token. You must have an underlying ERC20 deployed and specify its address. To use the wrapped token, call the `depositFor` function to deposit the original ERC20 tokens and receive wrapped tokens in return.
:::
### Import
```solidity
import "isol/contracts/kit/ERC20WrappedxWithAuthorize.sol";
```
### Usage
```solidity
// 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
| Parameter | Type | Description | |
| :---------------- | :-------- | :------------------------------------------------ | - |
| `underlyingToken` | `address` | The address of the underlying ERC20 token | |
| `name` | `string` | The name of your token | |
| `symbol` | `string` | The symbol (ticker) of your token | |
| `domainName` | `string` | EIP-712 domain name for signature verification | |
| `domainVersion` | `string` | EIP-712 domain version for signature verification | |
#### underlyingToken
* **Type:** `address`
The address of the underlying ERC20 token, e.g., `0x..1234`.
```ts
contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
constructor()
ERC20WrappedxWithAuthorize(
0x...YouERC20Address, // [!code focus] 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".
```ts
contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
constructor()
ERC20WrappedxWithAuthorize(
0x...YouERC20Address, // Underlying Token (address)
"WERC20xAuth Token", // [!code focus] 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".
```ts
contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
constructor()
ERC20WrappedxWithAuthorize(
0x...YouERC20Address, // Underlying Token (address)
"WERC20xAuth Token", // Name (string)
"WAUTH", // [!code focus] 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".
```ts
contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
constructor()
ERC20WrappedxWithAuthorize(
0x...YouERC20Address, // Underlying Token (address)
"WERC20xAuth Token", // Name (string)
"WAUTH", // Symbol (string)
"WERC20xAuth Token", // [!code focus] Domain Name (string)
"1" // Domain Version (string)
)
{}
}
```
#### domainVersion
* **Type:** `string`
The EIP-712 domain version used for signature verification, e.g., "1".
```ts
contract WrapERC20xAuth is ERC20WrappedxWithAuthorize {
constructor()
ERC20WrappedxWithAuthorize(
0x...YouERC20Address, // Underlying Token (address)
"WERC20xAuth Token", // Name (string)
"WAUTH", // Symbol (string)
"WERC20xAuth Token", // Domain Name (string)
"1" // [!code focus] Domain Version (string)
)
{}
}
```
### Functions
#### Read
| Function | Arguments | Description |
| :------------------ | :---------------------------------------- | :------------------------------------------------------- |
| `BURN_TYPEHASH` | - | Check the typehash used for burn authorization |
| `TRANSFER_TYPEHASH` | - | Check the typehash used for transfer authorization |
| `allowance` | owner (`address`), spender (`address`) | Check approved amount for spender |
| `authorizeState` | authorizer (`address`), nonce (`bytes32`) | Check authorization state |
| `balanceOf` | account (`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
| Function | Interact | Arguments | Description |
| :---------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------- |
| `approve` | user | spender (`address`), value (`uint256`) | Allow spender to use your tokens |
| `burn` | user | value (`uint256`) | Burn a specific amount of your tokens |
| `burnFrom` | user | account (`address`), value (`uint256`) | Burn a specific amount of your tokens from an account |
| `burnWithAuthorize` | user | from (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Burn tokens with authorization |
| `depositFor` | user | account (`address`), value (`uint256`) | Deposit tokens for an account |
| `renounceOwnership` | owner | - | Renounce ownership of the token |
| `transfer` | user | to (`address`), value (`uint256`) | Send tokens to another address |
| `transferFrom` | user | from (`address`), to (`address`), value (`uint256`) | Move tokens using allowance |
| `transferOwnership` | owner | newOwner (`address`) | Transfer ownership of the token |
| `transferWithAuthorize` | user | from (`address`), to (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Transfer tokens with authorization |
| `withdrawTo` | user | account (`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](../kit/ERC20xTransferWithAuthorize.mdx), with additional new features below.
| Function | Type | Interact | Arguments | Description |
| :----------- | :---- | :------- | :------------------------------------- | :---------------------------- |
| `underlying` | read | - | - | Check authorization state. |
| `depositFor` | write | user | account (`address`), value (`uint256`) | Deposit tokens for an account |
| `withdrawTo` | write | user | account (`address`), value (`uint256`) | Withdraw tokens to an account |
### References
Source code: [ERC20WrappedxWithAuthorize](./)
OpenZeppelin: [ERC20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20), [ERC20Burnable](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20burnable), [ERC20Wrapper](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20wrapper), [ReentrancyGuard](https://docs.openzeppelin.com/contracts/5.x/api/utils#reentrancyguard), [Ownable](https://docs.openzeppelin.com/contracts/5.x/api/access#Ownable)
### Examples
#### Deploy
```ts [./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
:::note
Recommend [dacc-js](https://dacc-js.thefactlab.org/functions/dacc-signature/sign-typed-data) an easy-to-use library for interactions, designed to scale your services from Web2 to Web3.
:::
:::info
Before **depositFor** make sure to approve the underlying token to this contract address.
:::
:::warning
Please ensure that you have sufficient token balance and gas fees in your wallet before performing token transfers.
:::
```ts [./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);
```
## 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
```solidity
import "isol/contracts/kit/ERC20xTransferWithAuthorize.sol";
```
### Usage
```solidity
// 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
| Parameter | Type | Description |
| :-------------- | :-------- | :---------------------------------------------------- |
| `name` | `string` | The name of your token |
| `symbol` | `string` | The symbol (ticker) of your token |
| `initialSupply` | `uint256` | The initial supply (whole number, no decimals needed) |
| `domainName` | `string` | EIP-712 domain name for signature verification |
| `domainVersion` | `string` | EIP-712 domain version for signature verification |
#### name
* **Type:** `string`
The name of your ERC20 token, e.g., "MyToken".
```ts
contract ERC20xAuth is ERC20xTransferWithAuthorize {
constructor()
ERC20xTransferWithAuthorize(
"ERC20xAuth Token", // [!code focus] 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".
```ts
contract ERC20xAuth is ERC20xTransferWithAuthorize {
constructor()
ERC20xTransferWithAuthorize(
"ERC20xAuth Token", // Name (string)
"AUTH", // [!code focus] 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.
```ts
contract ERC20xAuth is ERC20xTransferWithAuthorize {
constructor()
ERC20xTransferWithAuthorize(
"ERC20xAuth Token", // Name (string)
"AUTH", // Symbol (string)
1000000, // [!code focus] 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".
```ts
contract ERC20xAuth is ERC20xTransferWithAuthorize {
constructor()
ERC20xTransferWithAuthorize(
"ERC20xAuth Token", // Name (string)
"AUTH", // Symbol (string)
1000000, // Initial Supply (number: uint256)
"ERC20xAuth Token", // [!code focus] Domain Name (string)
"1" // Domain Version (string)
)
{}
}
```
#### domainVersion
* **Type:** `string`
The EIP-712 domain version used for signature verification, e.g., "1".
```ts
contract ERC20xAuth is ERC20xTransferWithAuthorize {
constructor()
ERC20xTransferWithAuthorize(
"ERC20xAuth Token", // Name (string)
"AUTH", // Symbol (string)
1000000, // Initial Supply (number: uint256)
"ERC20xAuth Token", // Domain Name (string)
"1" // [!code focus] Domain Version (string)
)
{}
}
```
### Functions
#### Read
| Function | Arguments | Description |
| :------------------ | :---------------------------------------- | :------------------------------------------------------- |
| `BURN_TYPEHASH` | - | Check the typehash used for burn authorization |
| `TRANSFER_TYPEHASH` | - | Check the typehash used for transfer authorization |
| `allowance` | owner (`address`), spender (`address`) | Check approved amount for spender |
| `authorizeState` | authorizer (`address`), nonce (`bytes32`) | Check authorization state |
| `balanceOf` | account (`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
| Function | Interact | Arguments | Description |
| :---------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------- |
| `approve` | user | spender (`address`), value (`uint256`) | Allow spender to use your tokens |
| `burn` | user | value (`uint256`) | Burn a specific amount of your tokens |
| `burnFrom` | user | account (`address`), value (`uint256`) | Burn a specific amount of your tokens from an account |
| `burnWithAuthorize` | user | from (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Burn tokens with authorization |
| `renounceOwnership` | owner | - | Renounce ownership of the token |
| `transfer` | user | to (`address`), value (`uint256`) | Send tokens to another address |
| `transferFrom` | user | from (`address`), to (`address`), value (`uint256`) | Move tokens using allowance |
| `transferOwnership` | owner | newOwner (`address`) | Transfer ownership of the token |
| `transferWithAuthorize` | user | from (`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](../kit/KitxERC20.mdx), with additional new features below.
| Function | Type | Interact | Arguments | Description |
| :---------------------- | :---- | :------- | :------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------- |
| `BURN_TYPEHASH` | read | - | - | Check the typehash used for burn authorization |
| `TRANSFER_TYPEHASH` | read | - | - | Check the typehash used for transfer authorization |
| `authorizeState` | read | - | authorizer (`address`), nonce (`bytes32`) | Check authorization state |
| `eip712Domain` | read | - | - | Check the EIP-712 domain used for signature verification |
| `burnWithAuthorize` | write | user | from (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Burn tokens with authorization |
| `transferWithAuthorize` | write | user | from (`address`), to (`address`), value (`uint256`), createTime (`uint256`), expireTime (`uint256`), nonce (`bytes32`), auth (`bytes`) | Transfer tokens with authorization |
### References
Source code: [ERC20xTransferWithAuthorize](./)
OpenZeppelin: [ERC20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20), [ERC20Burnable](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20burnable), [ReentrancyGuard](https://docs.openzeppelin.com/contracts/5.x/api/utils#reentrancyguard), [Ownable](https://docs.openzeppelin.com/contracts/5.x/api/access#Ownable)
### Examples
#### Deploy
```ts [./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
:::note
Recommend [dacc-js](https://dacc-js.thefactlab.org/functions/dacc-signature/sign-typed-data) an easy-to-use library for interactions, designed to scale your services from Web2 to Web3.
:::
:::warning
Please ensure that you have sufficient token balance and gas fees in your wallet before performing token transfers.
:::
```ts [./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);
```
## KitxERC20 \[isol/contracts/kit/KitxERC20.sol]
**Kit** The `KitxERC20` is a comprehensive and efficient core ERC20 smart contract suite, providing all essential features for modern token development.
### Import
```solidity
import "isol/contracts/kit/KitxERC20.sol";
```
### Usage
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "isol/contracts/kit/KitxERC20.sol";
contract Kit is KitxERC20 {
constructor()
KitxERC20(
"Kit Token",
"KIT",
1000000
)
{}
}
```
### Arguments
| Parameter | Type | Description |
| :-------------- | :-------- | :---------------------------------------------------- |
| `name` | `string` | The name of your token |
| `symbol` | `string` | The symbol (ticker) of your token |
| `initialSupply` | `uint256` | The initial supply (whole number, no decimals needed) |
#### name
* **Type:** `string`
The name of your ERC20 token, e.g., "MyToken".
```ts
contract Kit is KitxERC20 {
constructor()
KitxERC20(
"Kit Token", // [!code focus] Name (string)
"KIT", // Symbol (string)
1000000 // Initial Supply (number: uint256)
)
{}
}
```
#### symbol
* **Type:** `string`
The symbol (ticker) of your ERC20 token, e.g., "MTK".
```ts
contract Kit is KitxERC20 {
constructor()
KitxERC20(
"Kit Token", // Name (string)
"KIT", // [!code focus] Symbol (string)
1000000 // Initial Supply (number: uint256)
)
{}
}
```
#### 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.
```ts
contract Kit is KitxERC20 {
constructor()
KitxERC20(
"Kit Token", // Name (string)
"KIT", // Symbol (string)
1000000 // [!code focus] Initial Supply (number: uint256)
)
{}
}
```
### Functions
#### Read
| Function | Arguments | Description |
| :------------ | :------------------------------------- | :--------------------------------------- |
| `allowance` | owner (`address`), spender (`address`) | Check approved amount for spender |
| `balanceOf` | account (`address`) | Get token balance of an address |
| `decimals` | - | Get number of decimals used by the token |
| `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
| Function | Interact | Arguments | Description |
| :------------------ | :------- | :-------------------------------------------------- | :---------------------------------------------------- |
| `approve` | user | spender (`address`), value (`uint256`) | Allow spender to use your tokens |
| `burn` | user | value (`uint256`) | Burn a specific amount of your tokens |
| `burnFrom` | user | account (`address`), value (`uint256`) | Burn a specific amount of your tokens from an account |
| `renounceOwnership` | owner | - | Renounce ownership of the token |
| `transfer` | user | to (`address`), value (`uint256`) | Send tokens to another address |
| `transferFrom` | user | from (`address`), to (`address`), value (`uint256`) | Move tokens using allowance |
| `transferOwnership` | owner | newOwner (`address`) | Transfer ownership of the token |
### 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) |
### Features
Functions are inherited from [BasexERC20](../base/BasexERC20.mdx), with additional new features below.
| Function | Type | Interact | Arguments | Description |
| :------------------ | :---- | :------- | :------------------------------------- | :---------------------------------------------------- |
| `owner` | read | - | - | Get the owner of the token |
| `burn` | write | user | value (`uint256`) | Burn a specific amount of your tokens |
| `burnFrom` | write | user | account (`address`), value (`uint256`) | Burn a specific amount of your tokens from an account |
| `renounceOwnership` | write | owner | - | Renounce ownership of the token |
| `transferOwnership` | write | owner | newOwner (`address`) | Transfer ownership of the token |
### References
Source code: [KitxERC20](./)
OpenZeppelin: [ERC20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20), [ERC20Burnable](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20burnable), [Ownable](https://docs.openzeppelin.com/contracts/5.x/api/access#Ownable)
### Examples
#### Deploy
```ts [./MyToken.sol]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "isol/contracts/kit/KitxERC20.sol";
contract MyToken is KitxERC20 {
constructor()
KitxERC20(
"MyToken", // Name (string)
"MTK", // Symbol (string)
5000000 // Initial Supply (number: uint256)
)
{}
}
```
#### Interact
:::note
Recommend [dacc-js](https://dacc-js.thefactlab.org/functions/dacc-transactions/send-token) an easy-to-use library for interactions, designed to scale your services from Web2 to Web3.
:::
:::warning
Please ensure that you have sufficient token balance and gas fees in your wallet before performing token transfers.
:::
```ts [./interact.ts]
import { daccSendToken } from 'dacc-js';
import { optimismSepolia } from 'viem/chains'; // used `viem` - npm i viem
const tx = await daccSendToken({
// account: "0xPrivatekey...", // Can call with `allowDaccWallet` function
daccPublickey: 'daccPublickey_0x123_XxX..',
// address: '0x123address...', // Only the address created is set to `publicEncryption: true`
passwordSecretkey: 'my+Password#123..',
network: optimismSepolia,
tokenAddress: '0xTokenContract...',
to: '0xRecipient...',
amount: 0.1
// decimals: 6
});
console.log(tx); // {txHash, chainId, from, to, tokenAddress, amount, decimals}
console.log(tx?.txHash); // 0xTransactionHash...
```
## BasexERC20 \[isol/contracts/base/BasexERC20.sol]
**Base** The `BasexERC20` is a basic starting point for creating your own ERC20 token easily. Set the name, symbol, and initial supply right away.
### Import
```solidity
import "isol/contracts/base/BasexERC20.sol";
```
### Usage
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "isol/contracts/base/BasexERC20.sol";
contract Base is BasexERC20 {
constructor()
BasexERC20(
"Base Token",
"BASE",
1000000
)
{}
}
```
### Arguments
| Parameter | Type | Description |
| :-------------- | :-------- | :---------------------------------------------------- |
| `name` | `string` | The name of your token |
| `symbol` | `string` | The symbol (ticker) of your token |
| `initialSupply` | `uint256` | The initial supply (whole number, no decimals needed) |
#### name
* **Type:** `string`
The name of your ERC20 token, e.g., "MyToken".
```ts
contract Base is BasexERC20 {
constructor()
BasexERC20(
"Base Token", // [!code focus] Name (string)
"BASE", // Symbol (string)
1000000 // Initial Supply (number: uint256)
)
{}
}
```
#### symbol
* **Type:** `string`
The symbol (ticker) of your ERC20 token, e.g., "MTK".
```ts
contract Base is BasexERC20 {
constructor()
BasexERC20(
"Base Token", // Name (string)
"BASE", // [!code focus] Symbol (string)
1000000 // Initial Supply (number: uint256)
)
{}
}
```
#### 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.
```ts
contract Base is BasexERC20 {
constructor()
BasexERC20(
"Base Token", // Name (string)
"BASE", // Symbol (string)
1000000 // [!code focus] Initial Supply (number: uint256)
)
{}
}
```
### Functions
#### Read
| Function | Arguments | Description |
| :------------ | :------------------------------------- | :--------------------------------------- |
| `allowance` | owner (`address`), spender (`address`) | Check approved amount for spender |
| `balanceOf` | account (`address`) | Get token balance of an address |
| `decimals` | - | Get number of decimals used by the token |
| `name` | - | Get the name of the token |
| `symbol` | - | Get the symbol of the token |
| `totalSupply` | - | Get the total supply of the token |
#### Write
| Function | Interact | Arguments | Description |
| :------------- | :------- | :-------------------------------------------------- | :------------------------------- |
| `approve` | user | spender (`address`), value (`uint256`) | Allow spender to use your tokens |
| `transfer` | user | to (`address`), value (`uint256`) | Send tokens to another address |
| `transferFrom` | user | from (`address`), to (`address`), value (`uint256`) | Move tokens using allowance |
### Events
| Logs |
| :------------------------------------------------------------------------ |
| `Transfer`(address indexed from, address indexed to, uint256 value) |
| `Approval`(address indexed owner, address indexed spender, uint256 value) |
### Features
| Function | Type | Interact | Arguments | Description |
| :------- | :--- | :------- | :-------- | :---------- |
| - | - | - | - | - |
### References
Source code: [BasexERC20](./)
OpenZeppelin: [ERC20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#erc20)
### Examples
#### Deploy
```ts [./MyToken.sol]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
import "isol/contracts/base/BasexERC20.sol";
contract MyToken is BasexERC20 {
constructor()
BasexERC20(
"MyToken", // Name (string)
"MTK", // Symbol (string)
5000000 // Initial Supply (number: uint256)
)
{}
}
```
#### Interact
:::note
Recommend [dacc-js](https://dacc-js.thefactlab.org/functions/dacc-transactions/send-token) an easy-to-use library for interactions, designed to scale your services from Web2 to Web3.
:::
:::warning
Please ensure that you have sufficient token balance and gas fees in your wallet before performing token transfers.
:::
```ts [./interact.ts]
import { daccSendToken } from 'dacc-js';
import { optimismSepolia } from 'viem/chains'; // used `viem` - npm i viem
const tx = await daccSendToken({
// account: "0xPrivatekey...", // Can call with `allowDaccWallet` function
daccPublickey: 'daccPublickey_0x123_XxX..',
// address: '0x123address...', // Only the address created is set to `publicEncryption: true`
passwordSecretkey: 'my+Password#123..',
network: optimismSepolia,
tokenAddress: '0xTokenContract...',
to: '0xRecipient...',
amount: 0.1
// decimals: 6
});
console.log(tx); // {txHash, chainId, from, to, tokenAddress, amount, decimals}
console.log(tx?.txHash); // 0xTransactionHash...
```