# Implementation Guide

ERC 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

#### **Following the Specification**

After reading through ERC-5725, the main section you will focus on during integration will be the [ERC-5725 specification](https://eips.ethereum.org/EIPS/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](https://docs.soliditylang.org/en/v0.8.19/natspec-format.html) comments of the [ERC-5725 specification](https://eips.ethereum.org/EIPS/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](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation/blob/main/contracts/IERC5725.sol) is stored publicly on the GitHub [ERC-5725 reference implementation](http://github/). 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.

<details>

<summary>Implementing an ERC-5725 Contract</summary>

**Obtain the Base Contracts**

The simplest way to get started is to head to the [EIP-5725 Reference Implementation](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation) GitHub repository and click the button [**Use this template**](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation/generate) to quickly create a copy of the code under your own GitHub profile.

<img src="https://miro.medium.com/v2/resize:fit:1400/0*3osspHjzqTirWSXl" alt="" data-size="original">

*Click “*[*Use this template*](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation/generate)*” 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*

</details>

<details>

<summary>Extending ERC5725.sol: Easily Create Vesting NFTs</summary>

[ERC5725.sol](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation/blob/main/contracts/ERC5725.sol) is a valid IERC-5725 implementation which can be used as a base to quickly create Vesting NFTs.

#### // To Write <a href="#id-5068" id="id-5068"></a>

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**.

</details>

<details>

<summary>Full ERC5725 Implementation</summary>

#### // To Write <a href="#id-9dd7" id="id-9dd7"></a>

Two contracts are fully implemented in the [reference](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation/tree/main/contracts/referencehttps://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation/tree/main/contracts/reference) directory: **LinearVestingNFT** and **VestingNFT**.

Example [LinearVestingNFT](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation/blob/main/contracts/reference/LinearVestingNFT.sol)

* 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**

</details>

<details>

<summary>Implement Your Own!</summary>

#### // To Write <a href="#b4b8" id="b4b8"></a>

* 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!

</details>

#### **Resources** <a href="#af9e" id="af9e"></a>

* [Official Ethereum EIP-5725](https://eips.ethereum.org/EIPS/eip-5725)
* [ERC-5725 Reference Implementation (GitHub Template)](https://github.com/ApeSwapFinance/eip-5725-vesting-nft-implementation)
* [Ethereum Magicians EIP-5725 Forum Discussion](https://ethereum-magicians.org/t/eip-5725-transferable-vesting-nft/11099)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ape.bond/apebond/products-and-features/bonds/erc-5725-transferable-vesting-nft/implementation-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
