Skip to content

guildxyz/club-contracts

Repository files navigation

Seed Club smart contracts

The smart contracts in this repository are being used by Seed Club.

Requirements

To run the project you need:

  • Node.js development environment.
  • Truffle for compiling, deploying and testing (installed globally via npm).
  • (optional) Ganache for local testing (installed globally via npm).
  • A file named .env

Your .env file should contain the following:

  • Your 12-word MetaMask seedphrase for deploying: MNEMONIC='seedphrase'
  • Your Infura project ID for deploying to Ethereum networks: INFURA_ID='id'
  • Your Etherscan API key for verification the source code: ETHERSCAN_API_KEY='api key'

Tasks before deployment, usage

Pull the repository from GitHub, then install its dependencies by executing this command:

npm install

Merkle distributor contract

First you need to generate a Merkle tree. See section Generating a Merkle tree below.

Open migrations/4_deploy_distributor.js. Notice the top three constants:

const token = "0x..."; // the address of the token to be distributed
const merkleRoot = "0x..."; // the merkle root generated by scripts/generate-merkle-root.ts
const distributionDuration = "86400"; // the duration of the rewards distribution in seconds

Edit them according to your needs.
You can find the Merkle root in the previously generated json file.

Merkle vesting contract

Open migrations/5_deploy_vesting.js. Edit the constant at the top according to your needs:

const token = "0x..."; // the address of the token to be distributed

To add a new cohort to a deployed contract, you need to generate a Merkle tree. See section Generating a Merkle tree below.

Generating a Merkle tree

First, you'll need a .json file with the addresses you wish to ditribute rewards to and the respective token amounts in hexadecimal format. For help, take a look at the example.json file in the scripts folder.
Create a similarly structured file and place it next to the example file.
When you're ready, open a terminal in the project's directory and run this command (replace [filename] with the relative path and name of your file):

npm run generate-merkle-root -- -i [filename]

If the script succeeded, you should see a file named result.json in the scripts folder, containing the Merkle root and the data needed for individual users to claim their tokens.

Note

If you exported a csv from a software like Google Sheets, with amounts in a more human readable form (decimal form, whole tokens (not "wei")), you can easily convert that to the json needed by the above script. You only need to run this command:

npm run csv-to-json -- -i [filename]

If the script succeeded, you should see a file named readyInput.json in the scripts folder.

Deployment

To deploy the smart contracts to a network, replace [networkName] in this command:

truffle migrate --network [networkName]

Networks can be configured in truffle-config.js. We've preconfigured the following:

  • development (for local testing)
  • ethereum (Ethereum Mainnet)
  • goerli (Görli Ethereum Testnet)
  • kovan (Kovan Ethereum Testnet)
  • ropsten (Ropsten Ethereum Testnet)
  • bsc (Binance Smart Chain)
  • bsctest (Binance Smart Chain Testnet)
  • polygon (Polygon Mainnet (formerly Matic))
  • mumbai (Matic Mumbai Testnet)

Note

The above procedure deploys all the contracts. If you want to deploy only specific contracts, you can run only the relevant script(s) via the below command:

truffle migrate -f [start] --to [end] --network [name]

Replace [start] with the number of the first and [end] with the number of the last migration script you wish to run. To run only one script, [start] and [end] should match. The numbers of the scripts are:

  • 1 - Migrations
  • 2 - Seed Club Token
  • 3 - Seed Club Mint
  • 4 - Merkle distributor
  • 5 - Merkle vesting

If the script fails before starting the deployment, you might need to run the first one, too.

Verification

For automatic verification of the source code on Etherscan you can use truffle plugin verify:

truffle run verify [contractName] --network [networkName]

Tests

To run the unit tests written for this project, execute this command in a terminal:

npm test

About

Contracts for Seed Club's token launch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published