@ape.swap/erc-5725
v1.0.1
Published
ERC-5725: Transferrable Vesting NFT - Reference Implementation.
Downloads
39
Keywords
Readme
ERC-5725: Transferrable Vesting NFT - Reference Implementation
This repository serves as both a reference implementation and an sdk module for EIP-572 Transferrable Vesting NFT Standard.
EIP-5725
"A Non-Fungible Token (NFT) standard used to vest ERC-20 over a vesting release curve."
Find the official EIP located here.
Examples
The ethers example can be run quickly with yarn example
.
This solidity reference shows how to extend ERC5725.sol
to quickly create a transferrable vesting NFT.
@ape.swap/erc-5725
Package Usage
Installation
Add the ERC-5725 module to your Solidity, Frontend and/or Backend application.
npm install @ape.swap/erc-5725
# OR
yarn add @ape.swap/erc-5725
Usage with Solidity Smart Contracts
Extend ERC5725.sol
to quickly create a transferrable Vesting NFT contract implementation.
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
import "@ape.swap/erc-5725/contracts/ERC5725.sol";
contract LinearVestingNFT is ERC5725 { ... }
Usage with Frontend/Backend Node Applications
Quickly interact with an ERC5725 contract by providing an ethers
provider.
Quickly Read ERC-5725 Values
By simply passing an RPC provider URL, state from an ERC-5725 contract can be read quickly.
// Import ERC-5725 contract helper function
import { getERC5725Contract, IERC5725_Artifact } from '@ape.swap/erc-5725'
const IERC5725_ABI = IERC5725_Artifact.abi
import { ethers } from 'ethers'
// Very quickly send txs to/read from type safe ERC-5725 contract
const provider = await ethers.getDefaultProvider('https://bscrpc.com')
// Obtain a type safe ERC-7525 contract
const erc5725Contract = getERC5725Contract('<erc-5725-address>', provider)
// Read vestingPeriod
const { vestingStart, vestingEnd } = await erc5725Contract.vestingPeriod('<token-id>')
MetaMask Integration
By simply passing an RPC provider URL, state from an ERC-5725 contract can be read quickly.
// Import ERC-5725 contract helper function
import { getERC5725Contract, IERC5725_Artifact } from '@ape.swap/erc-5725'
const IERC5725_ABI = IERC5725_Artifact.abi
import { ethers } from 'ethers'
// Pull out the injected ethereum provider from MetaMask in browser
const { ethereum } = window
const provider = new ethers.providers.Web3Provider(ethereum)
const signer = provider.getSigner()
// Setup ERC-5725 instance with a signer
const erc5725Contract = getERC5725Contract('<erc-5725-address>', signer)
// Claim payoutTokens
const tx = await erc5725Contract.claim('<token-id>')
await tx.wait()
Usage via Clone
git clone [email protected]:ApeSwapFinance/eip-5725-vesting-nft-implementation.git
cd eip-5725-vesting-nft-implementation
yarn
- Copy .env.example and rename to
.env
- Provide the necessary
env
variables before deployment/verification MAINNET_MNEMONIC
/TESTNET_MNEMONIC
for deployments<explorer>_API_KEY
for verifications
- Provide the necessary
- hardhat.config.ts: Can be configured with additional networks if needed
Deployment and Verification
This project uses special tasks, adapted from Balancer protocol, to deploy and verify contracts which provides methods for saving custom outputs and easily verifying contracts as well as compartmentalizing different types of deployments.
Default (yarn script) Deployment and Verification
Deploy 20230212-vesting-nft task to the network of your choiceyarn deploy <network-name>
Verify 20230212-vesting-nft on the network of your choiceyarn verify <network-name> --name <LinearVestingNFT|VestingNFT>
Hardhat Deployment and Verification
Deploy using hardhat tasksnpx hardhat deploy --id 20230212-vesting-nft --network <network-name>
Verify using hardhat tasksnpx hardhat verify-contract --id 20230212-vesting-nft --network <network-name> --name <LinearVestingNFT|VestingNFT>
Linting
This project uses Prettier, an opinionated code formatter, to keep code styles consistent. This project has additional plugins for Solidity support as well.
Linting Solidity Code
prettier.config.js: Provide config settings for Solidity under
overrides
..solhint.json: Provide config settings for
solhint
.yarn lint
: Lint Solidity & TS/JS filesyarn lint:fix
: Fix Solidity & TS/JS files