Understanding and Developing an ERC-5725 Contract
Announcements

Understanding and Developing an ERC-5725 Contract

3ในการอ่าน
1 year ago

Understanding and Developing an ERC-5725 Contract

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

After reading through EIP-5725, the main section you will focus on during integration will be the EIP-5725 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.

During the integration process, take some time to read carefully through the natspec comments of the EIP-5725 specification to ensure you are implementing the functions the correct way. The key words above help define how the functions should work, given different inputs.

IERC5725.sol on GitHub

A usable IERC5725.sol is stored publicly on the GitHub ERC-5725 reference implementation. This can be used as the base for ERC-5725 NFTs.

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

The simplest way to get started is to head to the EIP-5725 Reference Implementation GitHub repository and click the button Use this template to quickly create a copy of the code under your own GitHub profile.

Click “Use this template” to copy the reference code

Otherwise, you can use git clone to copy the code locally, or even download the code in .ZIP files under the <> Code drop down.

$ 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

ERC5725.sol is a valid IERC-5725 implementation which can be used as a base to quickly create Vesting NFTs.

// To Write

ERC5725.sol is an abstract contract. To be able to implement ERC5725.sol you will need to import it into a parent contract and override 5 virtual functions:
  • 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

Two contracts are fully implemented in the reference directory: LinearVestingNFT and VestingNFT.
  • 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

0 people liked this article

Related Articles

Announcements
Phase 6 of “Super Start” IEO: SUI IEO will be launched on April 21
1 year ago
5ในการอ่าน
Crypto News
U.S. Secretary of State Blinken voices allies’ concerns on Sudan
As the violence in Sudan escalates, U.S. Secretary of State Antony Blinken has expressed the deep concern shared by allies at the G7 Foreign Ministers meeting in Japan. With the situation in Sudan ...
1 year ago
3ในการอ่าน
Crypto News
SEC declares six tokens as securities in Bittrex lawsuit
The U.S. Securities and Exchange Commission has filed a lawsuit against crypto exchange Bittrex, naming six tokens listed on the platform as securities. The tokens listed in the complaint are DASH,...
1 year ago
2ในการอ่าน
Announcements
Zentachain | $CHAIN Token Trade Upcoming IDO
The upcoming CHAIN token IDO is an exciting development for the Zentachain community, providing an exclusive opportunity for early participation.
1 year ago
2ในการอ่าน
Crypto News
SEC Commissioner Hester Peirce Details Dissent Against Gary Gensler’s Anti-Crypto Agenda
The Securities and Exchange Commission&#8217;s (SEC) Hester Peirce is speaking out against Chair Gary Gensler&#8217;s anti-crypto agenda. In a new lecture, Peirce criticizes the regulatory agency f...
1 year ago
3ในการอ่าน
Crypto News
Save easter eggs with 1xBit and win crypto
We have celebrated Easter, but its aura still hovers over the air, and the happiness it brings has been amplified by 1xBit, the crypto gambling site. The Easter Invaders’ Adventure is a new slot to...
1 year ago
4ในการอ่าน