- First, start up Ganache
- Click on settings (cog top right)
- Go to the "Accounts & Keys" tab
- Set the Mnemonic to match the seed words generated by MetaMask under settings and "Reveal Seed Words"
- Restart Ganache
- Test your Metamask connection to Ganache
You'll first need to set-up the contract before we can continue.
To build and migrate the contract run the following:
$ cd solidity
$ truffle migrate
Once it has migrated make note of the contract's address.
The output will look like this:
Using network 'development'.
Running migration: 1_initial_migration.js
Deploying Migrations...
... 0x5231df496194ed312b63b352b48b8ed1d51cf43ca472565d4eebff80a2dcb1e5
Migrations: 0x2411aa047ca7be82a189f8268dfea2009b7ab670
Saving successful migration to network...
... 0x39712854c026802e7a65af5928a78b1b6309f0e71e14366f6cb286b8907ae33d
Saving artifacts...
Running migration: 2_deploy_contracts.js
Deploying AddressBook...
... 0xc8f0c50442fe056eb667d20a31ea5f317e92784af10d1c7147e78d5788c50087
AddressBook: 0x897c95fed51d8b89a8a57d8bbe7f1522bf530571
Saving successful migration to network...
... 0x1c98ffba8159a5eeb0b4af3d51028884c0ca7c611c0213330cbb7573c7268faa
Saving artifacts...
You just need the part which says:
AddressBook: 0x897c95fed51d8b89a8a57d8bbe7f1522bf530571
In public/src/scripts/controllers/addresses.js
paste this address on line 12 wrapped in quotes.
This will have also generated a directory called build
. If you change the structure of the address book contract you will need to:
- Inside
solidity/build/contracts/AddressBook.json
there is a json structure, at the first level there is an "abi" object - Copy the entire value of this abi into
public/src/scripts/contracts/addressbook.json
Now you've set-up Truffle we can build the web application.
The first thing we will need to do is get grunt installed by running:
$ cd public
$ npm update
$ grunt
This will build, minify and serve the application at http://localhost:8000