This is a very basic front-end application which deploys a voting based smart contract to the Ethereum blockchain (test or main). Once deployed, we can interact with the contract using addresses which have enough ether to pay for the gas required of the desired function call on the contract.
Example webpack project with Truffle. Includes contracts, migrations, tests, user interface and webpack build pipeline.
To initialize a project with this exapmple, run truffle init webpack
inside an empty directory.
- First run
truffle compile
, then runtruffle migrate
to deploy the contracts onto your network of choice (default "development"). - Then run
npm run dev
to build the app and serve it on http://localhost:8080
- Use the webpack hotloader to sense when contracts or javascript have been recompiled and rebuild the application. Contributions welcome!
- Error: Can't resolve '../build/contracts/MetaCoin.json'
This means you haven't compiled or migrated your contracts yet. Run truffle compile
and truffle migrate
first.
Full error:
ERROR in ./app/main.js
Module not found: Error: Can't resolve '../build/contracts/MetaCoin.json' in '/Users/tim/Documents/workspace/Consensys/test3/app'
@ ./app/main.js 11:16-59