A tokenbound ERC20 is an ERC20 contract which is bound permanently to an NFT. The holder of the NFT has the sole and irrevocable authority to mint tokens on the tokenbound ERC20 contract to anyone they choose.
This authority transfers with the NFT.
This repository implements two contracts:
TokenboundERC20
- the actual ERC20 implementation which confers minting privileges to the holder of the binding NFT.BindingERC721
- an ERC721 implementation which is responsible for the deployment of the tokenbound account and the tokenbound ERC20 contract bound to each of its NFTs.
Every time an NFT is minted on the BindingERC721
contract, it deploys a tokenbound account and a tokenbound ERC20 contract
which respects the minting authority of that tokenbound account (and only that tokenbound account).
In this architecture, the ERC721 contract is self-aware in the sense that it has a canonical Tokenbound registry and account implementation which it uses to configure its Tokenbound ERC20 contracts.
Tokenbound ERC20s originated as a mechanic in our permissionless game, The Degen Trail, which is being developed in partnership with OP Games.
We intend to use Tokenbound ERC20s as a system in other games, and feel they might be useful even outside of the scope of our games. This is why we are releasing them in a standalone repository.
The smart contracts project can be built and tested using Foundry.
To build:
forge build
To test:
forge test -vvv
For technical documentation:
forge doc --serve
(You can read the technical documentation directly from the repo using this index.)
make
, make test
, etc. Look at the Makefile.