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
import "isol/contracts/base/BasexERC20.sol";Usage
// 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".
contract Base is BasexERC20 {
constructor()
BasexERC20(
"Base Token", // Name (string)
"BASE", // Symbol (string)
1000000 // Initial Supply (number: uint256)
)
{}
}symbol
- Type:
string
The symbol (ticker) of your ERC20 token, e.g., "MTK".
contract Base is BasexERC20 {
constructor()
BasexERC20(
"Base Token", // Name (string)
"BASE", // 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.
contract Base is BasexERC20 {
constructor()
BasexERC20(
"Base Token", // Name (string)
"BASE", // Symbol (string)
1000000 // 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
Examples
Deploy
./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
./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...