Skip to content

Instantly share code, notes, and snippets.

@zaa
Last active October 4, 2022 12:12
Show Gist options
  • Save zaa/7451a51a8400e93f53ab3c53257e591b to your computer and use it in GitHub Desktop.
Save zaa/7451a51a8400e93f53ab3c53257e591b to your computer and use it in GitHub Desktop.
# ERC20
## Spec
- https://eips.ethereum.org/EIPS/eip-20
## Implementation
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol
## API
- [required, read] function totalSupply() external view returns (uint256)
- [required, read] function balanceOf(address account) external view returns (uint256)
- [required, read] function allowance(address owner, address spender) external view returns (uint256)
- [required, write] function approve(address spender, uint256 amount) external returns (bool)
- [required, write] function transfer(address to, uint256 amount) external returns (bool)
- [required, write] function transferFrom(address from, address to, uint256 amount) external returns (bool)
- [optional, read] function name() public view virtual override returns (string memory)
- [optional, read] function symbol() public view virtual override returns (string memory)
- [optional, read] function decimals() public view virtual override returns (uint8)
# ERC721
## Spec
- https://eips.ethereum.org/EIPS/eip-721
## Implementation
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/IERC721.sol
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/IERC721Metadata.sol
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/ERC721Enumerable.sol
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol
## API
- [required, read] function supportsInterface(bytes4 interfaceId) external view returns (bool) // Note: the ERC-165 identifier for ERC721 interface is 0x80ac58cd.
- [required, read] function balanceOf(address owner) external view returns (uint256 balance)
- [required, read] function ownerOf(uint256 tokenId) external view returns (address owner)
- [required, write] function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external
- [required, write] function safeTransferFrom(address from, address to, uint256 tokenId) external
- [required, write] function transferFrom(address from, address to, uint256 tokenId) external
- [required, write] function approve(address to, uint256 tokenId) external
- [required, write] function setApprovalForAll(address operator, bool _approved) external
- [required, read] function getApproved(uint256 tokenId) external view returns (address operator)
- [required, read] function isApprovedForAll(address owner, address operator) external view returns (bool)
- [optional, read] function name() external view returns (string memory)
- [optional, read] function symbol() external view returns (string memory)
- [optional, read] function tokenURI(uint256 tokenId) external view returns (string memory)
- [optional, read] function totalSupply() public view virtual override returns (uint256)
- [optional, read] function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256)
- [optional, read] function tokenByIndex(uint256 index) public view virtual override returns (uint256)
# ERC1155
## Spec
- https://eips.ethereum.org/EIPS/eip-1155
## Implementation
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/IERC1155.sol
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol
## API
- [required, read] function supportsInterface(bytes4 interfaceId) external view returns (bool) // Note: the ERC-165 identifier for ERC1155 interface is 0xd9b67a26
- [required, read] function balanceOf(address account, uint256 id) external view returns (uint256)
- [required, read] function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory)
- [required, write] function setApprovalForAll(address operator, bool approved) external
- [required, read] function isApprovedForAll(address account, address operator) external view returns (bool)
- [required, write] function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external
- [required, write] function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external
- [optional, read] function uri(uint256 id) external view returns (string memory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment