generated from ERC-5725/ERC-5725-reference
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8f82a63
Showing
53 changed files
with
320,222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Seed phrase used for mainnet deployments | ||
MAINNET_MNEMONIC= | ||
# Seed phrase used for testnet deployments | ||
TESTNET_MNEMONIC= | ||
|
||
# EVM Explorer API Keys (For Verification) | ||
ETHERSCAN_API_KEY= | ||
BSCSCAN_API_KEY= | ||
POLYGONSCAN_API_KEY= | ||
OPTIMISTIC_ETHERSCAN_API_KEY= | ||
ARBISCAN_API_KEY= | ||
|
||
# Options | ||
REPORT_GAS= | ||
|
||
# (Optional overrides) RPC URLS | ||
MAINNET_RPC_URL= | ||
ROPSTEN_RPC_URL= | ||
BSC_RPC_URL= | ||
BSC_TESTNET_RPC_URL= | ||
POLYGON_RPC_URL= | ||
POLYGON_TESTNET_RPC_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: lint & test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
node: ['16.x'] | ||
os: [ubuntu-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- run: npm install -g yarn | ||
|
||
- id: yarn-cache | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.yarn-cache.outputs.dir }} | ||
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ matrix.os }}-yarn- | ||
- run: yarn | ||
- run: yarn lint:ci | ||
- run: yarn test:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
node_modules | ||
.vscode | ||
.env | ||
coverage | ||
coverage.json | ||
typechain | ||
typechain-types | ||
|
||
#Hardhat files | ||
cache | ||
artifacts | ||
|
||
#Module | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"require": "hardhat/register", | ||
"timeout": 40000, | ||
"_": [ | ||
"test/**/*.ts" | ||
], | ||
"DEV-COMMENTS": { | ||
"warning": "Running test directly from Visual Studio Code won't compile your contracts automatically. Make sure compile them manually.", | ||
"source": "https://hardhat.org/hardhat-runner/docs/advanced/vscode-tests" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Use this file to ignore .sol files from solhint linting |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# ERC-5725: Transferrable Vesting NFT - Reference Implementation | ||
[![lint & test](https://github.com/ERC-5725/ERC-5725-reference/actions/workflows/lint-test.yml/badge.svg)](https://github.com/ERC-5725/ERC-5725-reference/actions/workflows/lint-test.yml) | ||
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-yellow)](./docs/) | ||
[![License](https://img.shields.io/badge/License-GPLv3-green.svg)](https://www.gnu.org/licenses/gpl-3.0) | ||
|
||
This repository serves as both a reference implementation and an sdk module for ERC-5725 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](https://eips.ethereum.org/EIPS/eip-5725). | ||
|
||
## Examples | ||
|
||
The [ethers example](./examples/getVestingPeriod.ts) can be run quickly with `yarn example`. | ||
|
||
This [solidity reference](./contracts/reference/LinearVestingNFT.sol) shows how to extend `ERC5725.sol` to quickly create a transferrable vesting NFT. | ||
|
||
## `@erc-5725/sdk` Package Usage | ||
|
||
### Installation | ||
|
||
Add the ERC-5725 module to your Solidity, Frontend and/or Backend application. | ||
|
||
```shell | ||
npm install @erc-5725/sdk | ||
# OR | ||
yarn add @erc-5725/sdk | ||
``` | ||
|
||
### Usage with Solidity Smart Contracts | ||
|
||
Extend `ERC5725.sol` to quickly create a transferrable Vesting NFT contract implementation. | ||
|
||
```js | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.0; | ||
|
||
import "@erc-5725/sdk/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. | ||
|
||
```ts | ||
// Import ERC-5725 contract helper function | ||
import { getERC5725Contract, IERC5725_Artifact } from '@erc-5725/sdk' | ||
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. | ||
|
||
```ts | ||
// Import ERC-5725 contract helper function | ||
import { getERC5725Contract, IERC5725_Artifact } from '@erc-5725/sdk' | ||
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 git@github.com:ERC-5725/ERC-5725-reference.git` | ||
- `cd ERC-5725-reference` | ||
- `yarn` | ||
- Copy [.env.example](./.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 | ||
- [hardhat.config.ts](./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](./tasks/20230212-vesting-nft/) task to the network of your choice | ||
`yarn deploy <network-name>` | ||
|
||
<br> | ||
|
||
Verify [20230212-vesting-nft](./tasks/20230212-vesting-nft/) on the network of your choice | ||
`yarn verify <network-name> --name <LinearVestingNFT|VestingNFT>` | ||
|
||
#### Hardhat Deployment and Verification | ||
|
||
Deploy using hardhat tasks | ||
`npx hardhat deploy --id 20230212-vesting-nft --network <network-name>` | ||
|
||
<br> | ||
|
||
Verify using hardhat tasks | ||
`npx 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](./prettier.config.js): Provide config settings for Solidity under `overrides`. | ||
- [.solhint.json](./.solhint.json): Provide config settings for `solhint`. | ||
|
||
- `yarn lint`: Lint Solidity & TS/JS files | ||
- `yarn lint:fix`: Fix Solidity & TS/JS files |
Oops, something went wrong.