The setup in this repository can be used as a quick starting point for smart contract development.
A version using Hardhat is available here.
To run the project you need Node.js development environment.
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.
If you have anything to add about the usage of the contracts or the migration files need variable parameters, mention them here.
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)sepolia
(Sepolia 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))arbitrum
(Arbitrum One (Mainnet))
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 - MyContract
For source code verification on block explorers, you can use truffle plugin verify.
truffle run verify [contractName] --network [networkName]
The project uses solhint. To run it, simply execute:
npm run lint
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 MyContract:
npm test ./test/MyContractTest.js