Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.41 KB

COMMANDS.md

File metadata and controls

39 lines (30 loc) · 1.41 KB

Steps to run after changing a smart contract:

Some instructions to run if debugging in truffle console.

Always keep notice that we cannot simply assign values to variable from smart contracts because of the asynchronous nature. So we have to use promises to do that.

  1. We need to re-deploy our smart contract in the block chain so we have to migrate it with the command truffle migrate --reset This resets the smart contract on the blockchain.

  2. We can check the deployed smart contract by running truffle console.

  3. In the console we have to first create an app variable with the running instance of the block chain. So for that run

    Election.deployed().then(i => { newInstance = i });
  4. For converting a BigNumber to JS integer use

    anyBigNumber.toNumber()
  5. Assigning a value can be done using promise or then() function.

    app.getData('507f1f77bcf86cd799439011').then(data => tuple =  data)
  6. For accessing accounts you can use web3.eth.accounts. This will return array of accounts available.

  7. For calling functions that write to the blockchain we have to use the above mentioned accounts. We can call functions like this

    newInstance.generateCertificate(
      certificate_id,
      candidate_id,
      org_id,
      expiration_date,
      {
        from: web3.eth.accounts[0]
      }
    );