MultiToken
MultiToken is a solidity library unifying ERC20, ERC721 & ERC1155 transfers by wrapping them into a MultiToken Asset struct.
- Source code
- If you want to use the MultiToken library in your solidity project you can install our NPM package.
- Run:
npm install @pwnfinance/multitoken
- MultiToken.sol contract is written in Solidity version 0.8.0, but can be compiled with any solidity compiler version 0.8.*
The library defines a token asset as a struct of token identifiers. It wraps transfer, allowance and balance check calls of the following token standards:
- ERC20
- ERC721
- ERC1155
Unifying the function calls used within the PWN context, so we don't have to worry about handling these token standards individually.
Function for transfer calls on various token interfaces.
This function takes two arguments:
address
_dest
- Destination address
Function for transfer from calls on various token interfaces.
This function takes three arguments:
address
_source
- Account/address that provided the allowanceaddress
_dest
- Destination address
Function for checking balances on various token interfaces.
This function takes two arguments:
address
_target
- Target address to be checked
Function for approving calls on various token interfaces.
This function takes two arguments:
address
_target
- Target address to be checked
Each asset is defined by the
Asset
struct and has the following properties:Type | Name | Comment |
---|---|---|
address | assetAddress | Address of the token contract defining the asset |
MultiToken.Category (category is described below) | category | Corresponding asset category |
uint256 | amount | Amount of fungible tokens or 0 -> 1 |
uint256 | id | TokenID of an NFT or 0 |
MultiToken library does not define any events or custom errors.
Last modified 6mo ago