This Ledgerium Truffle box gives you a boilerplate to get up and running quickly with Truffle. This allows you to allow you to do public and private transactions over Ledgerium blockchain.
Ensure you are in a new and empty directory.
1. Run the unbox command with npx and directly go to step 3. This will install all the necessary dependencies.
npx truffle unbox ledgerium-io/truffle-ledgerium-box
2. Alternatively, you can install Truffle globally and then run the unbox command.
npm install -g truffletruffle unbox ledgerium-io/truffle-ledgerium-box
3. Run the development console. This will instantiate a local chain for you to test that Truffle is working properly.
truffle develop
4. Ensure that you're able to compile, test and finally migrate your contracts to your local chain.
compiletestmigrate
5. If everything looks good, you can exit the Truffle console with .exit.
Connect to Ledgerium blockchain
In Ledgerium, select the node you want to connect to, then choose + Connect Node.
Select Native JSON/RPC
Choose an application credential to use for this connection.
Choose the Truffle Suite
connection type.
Copy the connection info from this panel into the respective variables inside of truffle-config.js. If you are using Quorum in this environment, ensure to uncomment the type: "quorum" property on your network object.
Migrate your contracts to your Producer node in Ledgerium Blockchain! truffle migrate
Configure truffle-config.js file
Under the networks section, provide the values of the Ledgerium Blockchain node. make sure that from
address is valid and has enough balance.
module.exports = {networks: {development: {host: 'flinders01.ledgerium.io',port: 8545,network_id: '*', // Match any network idfrom: '0xa819e7ddd125fa5cd6506f2bdc83562185b1ed87'}},solc: {// Turns on the Solidity optimizer. For development the optimizer's// quite helpful, just remember to be careful, and potentially turn it// off, for live deployment and/or audit time. For more information,// see the Truffle 4.0.0 release notes.//// https://github.com/trufflesuite/truffle/releases/tag/v4.0.0optimizer: {enabled: true,runs: 200}},ignore: ["README.md",".gitignore"],commands: {"Compile": "truffle compile","Migrate": "truffle migrate","Test contracts": "truffle test","Test dapp": "npm test","Run dev server": "npm run start","Build for production": "npm run build"},hooks: {"post-unpack": "npm install"}};
2. Run npm install
in client
and api
folders.
$ cd client$ npm install$ cd ../api$ npm install
3. Bring up Frontend and Backend applications.
node client/Server.jsnode api/Application.js
4. Access frontend using http://localhost:4000
5. Click on 'Get Accounts' to view the list of accounts
6. Click on Public
to interact with Invoice Contract using public transactions
7. Under Add Invoice ID
section, provide Invoice ID and Invoice Hash. Clicking on submit will pop up Ledgerium wallet. Sign the transaction and confirm it to write the transaction to a block.
8. Under Is Hash Exists
section, provide Invoice Hash and click on Is Hash Exists
to see if that Invoice Hash exists.
9. Under Get Invoice ID
section, provide Invoice Hash and click on Get Invoice ID
to get Invoice ID corresponding to Invoice Hash.