Skip to content

schronck/contracts-base

Repository files navigation

Smart contract development base - Truffle

The setup in this repository can be used as a quick starting point for smart contract development.

A version using Hardhat is available here.

Setup

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.

Some additional steps before deployment

If you have anything to add about the usage of the contracts or the migration files need variable parameters, mention them here.

Contract 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)
  • 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))

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 - MyContract

Verification

For source code verification on block explorers, 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 MyContract:

npm test ./test/MyContractTest.js

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published