Skip to content

Files

Latest commit

32a9701 · Dec 23, 2022

History

History
107 lines (72 loc) · 3.33 KB

README.md

File metadata and controls

107 lines (72 loc) · 3.33 KB

Token.xyz smart contracts

The smart contracts in this repository are the core of token.xyz.

Detailed documentation can be found in the docs folder.

Setup

To run the project you need:

  • Node.js development environment (version 14 or newer).
  • Truffle for compiling, deploying and testing (version 5.4.30 or newer).
  • Ganache environment for local testing (version 7.6.0 or newer).

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

npm install

Certain actions, like deploying to a public network or verifying source code on block explorers, need environment variables in a file named .env. See .env.example for more info.

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)
  • rinkeby (Rinkeby Ethereum Testnet)
  • ropsten (Ropsten Ethereum Testnet)
  • bsc (BNB Smart Chain)
  • bsctest (BNB Smart Chain Testnet)
  • polygon (Polygon Mainnet (formerly Matic))
  • mumbai (Matic Mumbai Testnet)
  • gnosis (Gnosis Chain (formerly xDai Chain))

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 (Truffle feature, optional)
  • 2 - Full- or InitialMigration & TokenXyz
  • 3 - SimpleFunctionRegistryFeature & OwnableFeature & MulticallFeature
  • 4 - TokenFactoryFeature & TokenWithRolesFactoryFeature
  • 5 - MerkleDistributorFactoryFeature
  • 6 - MerkleVestingFactoryFeature
  • 7 - ERC721MerkleDropFactoryFeature
  • 8 - ERC721CurveFactoryFeature
  • 9 - ERC721AuctionFactoryFeature

Extended instructions

For more detailed instructions, see the extended version of the deployment instructions.

Verification

For automatic verification you can use truffle-plugin-verify.

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

Linting

The project uses Solhint. To run it, simply execute:

npm run lint

Tests

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

npm test

To run the unit tests only in a specific file, just append the path to the command. For example, to run tests just for TokenFactory:

npm test ./test/TokenFactoryTest.js

Documentation

The documentation for the contracts is generated via the solidity-docgen package. Run the tool via the following command:

npm run docgen

The output can be found in the docs folder.