Initial scaffolding thanks to: https://github.com/wespr/truffle-vue
-
Install Truffle and an Ethereum client - like EthereumJS TestRPC. Note I couldn't get this to work on our VMs so I installed them directly on the Mac.
[sudo] npm install -g truffle // Version 3.0.5+ required. [sudo] npm install -g ethereumjs-testrpc
-
Pull down the repo and install dependancies
git clone https://github.com/jsaur/lending-dapp npm install
-
Launch
testrpc
in it's own command prompt tab.testrpc <options>
-
Compile and migrate the contracts.
truffle compile truffle migrate
-
Run the webpack server for front-end hot reloading. Smart contract changes do not support hot reloading for now.
npm run start
This box comes with everything bundled for unit
, e2e
and truffle
contracts testing. The tests are incomplete at the moment.
-
unit
ande2e
tests.npm run test/dapp
-
truffle
contracts tests.npm run test/truffle
-
Alternatively you can directly run
unit
,e2e
andtruffle
contracts tests in one command.npm run test
To build the application for production, use the build command. A production build will be compiled in the dist
folder.
npm run build
-
Install Metamask in your browser: https://metamask.io/
-
Change network to: Localhost 8545
-
When you started testrpc, it should have printed out a list of available accounts and private keys. Copy one of the private keys.
-
In meta mask, click the circular arrows, then "Import Account", then paste the private key. Now you can spend your test accounts ether.
I find that writing, compiling and testing solidity smart contracts is easiest using: https://ethereum.github.io/browser-solidity/
-
Launch Mist against your private network. Need to download it for your Mac first. Install location may vary.
cd /Volumes/Macintosh HD/Applications/Mist.app/Contents/MacOS ./Mist --rpc localhost:8545
-
Add contract The address and name are created when running truffle migrate The json interface can be found under build/contracts, the section under "abi"
Note: I've found Mist on testrpc to only be useful for reads - writes fail with a "_signAndSendTransaction not supported" error that seems to be an outstanding Mist issue.
-
If you're getting npm errors try:
npm update --scripts-prepend-node-path=auto
-
If you're getting 'out of gas' errors, increase the gas in truffle.js
gas: 460000000
-
If you're getting 'Exceeds block gas limit' errors, increase the gas limit on testrpc
testrpc --gasLimit 50000000
-
If you're getting 'invalid opt code' errors, try starting over
truffle compile truffle migrate --reset
-
If you're getting javascript errors when interacting with you contracts, double check the 'abi' section of your contract json in /build/contracts and compare to what the function actually looks like in Solidity. Sometimes truffle compile doesn't update these properly. If you delete all the files in build/contracts and then recompile everything it often fixes it.
npm run truffle migrate --reset --compile-all
-
Metamask issues: sometimes Metamask is unresponsive. I've found the best way is to disable, then re-enable metamask from the chrome extensions page.