This is a standard truffle package layout:
/contracts/
- solidity contracts source code/migrations/
- truffle migrations that deploy contracts to the blockchain/build/
- compiled contracts/test/
- contracts tests/webapp/
- standalone web application
$ npm install
Runs npm install
for /webapp
and /testrpc
in postinstall
script.
$ npm run testrpc
TestRPC acts like a local chain for testing and developement. It does not persist any state between runs.
In addition to running TestRPC, this command also compiles and deploys contracts to TestRPC. It removes previously built ABIs from build/contracts to smooth local development, but this behaviour is not suitable for deployment to any public network.
$ npm run test
$ npm run compile
This generates contracts ABIs (compiled interfaces) in /build/
directory.
$ npm run migrate
This published contracts to the blockchain and copies their generated
addresses to their interfaces stored in /build/
.
Note that if you're running npm run testrpc
contracts are compiled and migrated automatically, without a need for compile and migrate.
Normally, each time testrpc is started contracts would have to be migrated.
cd webapp
npm run start
Note that web application requires contracts to be compiled and
deployed first. It directly imports their interfaces from json files
in ./build/
.
When running for the first time:
- Open metamask (Click on the fox icon in menubar)
- Connect to localhost (Click on the network in the upper left corner and choose "localhost 8545")
- Import TestRPC account (Click "Import existing DEN")
- Provide a seed: "spike dizzy clump wrist receive limb interest half item lunch betray vivid"
(it comes from TestRPC output and is hardcoded
package.json
)
- Provide a seed: "spike dizzy clump wrist receive limb interest half item lunch betray vivid"
(it comes from TestRPC output and is hardcoded
- Each time TestRPC is restarted, browser has to be restarted as well.
- After each migration webapp should be reloaded
- If you're getting VM Errors in migrations
rm -r /build/
. Happens especially after switching branches.