Understanding and Developing an ERC-5725 Contract
Ethereum Improvement Proposal 5725: Transferable Vesting NFTs is an EIP created to offer a standardized Non-Fungible Token (NFT) API to enable vesting ERC-20 tokens over a vesting release curve. Read on to learn more about how to implement EIP-5725 for your own use cases, and feel free to reach out to ApeTastic, coauthor of the EIP, on Telegram at @Ape_tastic with any questions.
Following the Specification
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
IERC5725.sol on GitHub
Follow along below for how to use this interface to create your own ERC-5725 NFTs.
Implementing an ERC-5725 Contract
Obtain the Base Contracts
Click “Use this template” to copy the reference code
$ git clone git@github.com:ApeSwapFinance/eip-5725-vesting-nft-implementation.git$ cd eip-5725-vesting-nft-implementation
Use git clone to pull the reference code
Extending ERC5725.sol: Easily Create Vesting NFTs
// To Write
- vestedPayoutAtTime: Total amount of vested tokens at the provided timestamp for a given tokenId. This number also includes vested tokens which have been claimed.
- _payoutToken: Payout token of a given tokenId.
- _payout: The total payout of a given tokenId.
- _startTime: The unix timestamp of when vesting starts for a given tokenId.
- _endTime: The unix timestamp of when vesting ends for a given tokenId.
Full ERC5725 Implementation// To Write
- Extend ERC5725 by importing it: contract LinearVestingNFT is ERC5725
- It can be seen in this implementation that the five virtual functions above are implemented in this contact with override specifiers
- vestedPayoutAtTime is the central place to be able to change the vesting curve. In this case, it first checks that the _cliff has passed, otherwise it will linearly release tokens between the _startTime and _endTime
Implement Your Own!// To Write
- ERC5725.sol is a great starting place to easily get off the ground with Vesting NFTs.
- Use the reference implementations shared above as a guide to easily implement your own!
Resources