Skip to main content

ERC20

import "@thirdweb-dev/contracts/eip/interface/IERC20.sol";

ERC20 is the standard for representing fungible tokens; where each token is of equal valuable and interchangeable.

info

This extension is an interface and requires all of the functions to be implemented


Usage

This is an example smart contract demonstrating how to inherit from this extension and override the functions to add (optional) custom functionality.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@thirdweb-dev/contracts/eip/interface/IERC20.sol";

contract Contract is IERC20 {
constructor(
string memory _name,
string memory _symbol
) {}

function totalSupply() external view returns (uint256) {
// Your custom implementation here
}

function balanceOf(address who) external view returns (uint256) {
// Your custom implementation here
}

function allowance(address owner, address spender) external view returns (uint256) {
// Your custom implementation here
}

function transfer(address to, uint256 value) external returns (bool) {
// Your custom implementation here
}

function approve(address spender, uint256 value) external returns (bool) {
// Your custom implementation here
}

function transferFrom(
address from,
address to,
uint256 value
) external returns (bool); {
// Your custom implementation here
}
}

Click here to view an example implementation:

SDK Usage

By adding this extension to a smart contract, the following features, hooks and functions are unlocked in the SDK:

Base Contracts Implementing This Extension