An OpenZeppelin Starter Kit Tutorial containing React, OpenZeppelin CLI, OpenZeppelin Contracts, and Infura.
This kit comes with everything you need to start using upgradeable Smart contracts inside your applications. It also includes all the configuration required to deploy to different networks.
In addition to the contents included in the vanilla Starter Kit, this kit contains a step-by-step tutorial on how to use the OpenZeppelin SDK to develop your decentralized application.
Install Ganache.
npm install [email protected]
Ensure you are in a new and empty directory, and run the unpack
command with tutorial
to create a starter project:
npx @openzeppelin/cli unpack tutorial
In a new terminal window, run your local blockchain:
ganache-cli --deterministic
In your original terminal window, at the top level of your folder, initialize the project and follow the prompts:
npx openzeppelin init
After that compile the contracts:
npx openzeppelin compile
In a new terminal window, in the client
directory, run the React app:
cd client
npm run start
You can interact directly with your smart contracts from the openzeppelin
cli.
npx openzeppelin transfer
send funds to a given address.
npx openzeppelin balance [address]
query the ETH balance of the specified account, also supports ERC20s.
npx openzeppelin send-tx
sends a transaction to your contract and returns the events.
npx openzeppelin call
execute a constant method and receive back the value.
Type npx openzeppelin
to see a complete list of availible commands.
This starter kit uses Test Environment for smart contracts tests. Tests are written with Mocha, OpenZeppelin TestHelpers and Web3.js. ./test/counter.js
and ./test/wallet.js
files are good starting point for writing your own tests.
npm run test
During development it is helpful to run nodemon -e sol,js -x 'oz compile && npm test -- --bail'
. This will rerun tests on changes at .sol
and .js
files.
Jest is included for testing React components. Compile your contracts before running Jest, or you may receive some file not found errors.
// ensure you are inside the client directory when running this
npm run test
To build the application for production, use the build script. A production build will be in the client/build
folder.
// ensure you are inside the client directory when running this
npm run build
Solidity Hot Loader allows seamless updates to frontend by just editing and saving Solidity code. To enable change disabled
flag in client/config/webpack.js
file to false
.
-
Where is my production build?
The production build will be in the
client/build
folder after runningnpm run build
in theclient
folder. -
Where can I find more documentation?
Check out the OpenZeppelin Starter Kits documentation.