Using Truffle

There are a few technical requirements before we start. Please install the following:

Once we have those installed, we only need one command to install Truffle:

npm install -g truffle

To verify that Truffle is installed properly, type truffle version on a terminal. If you see an error, make sure that your npm modules are added to your path.

If you're new to Truffle then please follow the Getting Started by truffle, To setup the truffle environment.

truffle-config

  • Go to truffle-config.js

  • Update the truffle-config with rupto-network-crendentials.

const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
    },
    rupto: {
      provider: () => new HDWalletProvider(mnemonic, `https://testnet.rbcscan.com/`),
      network_id: 8898,
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: true
    },
  },

  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
    }
  }
}

Notice, it requires mnemonic to be passed in for Rupto Chain network, this is the seed phrase for the account you'd like to deploy from. Create a new .secret file in root directory and enter your 12 word mnemonic seed phrase to get started. To get the seedwords from metamask wallet you can go to Metamask Settings, then from the menu choose Security and Privacy where you will see a button that says reveal seed words.

Deploying on Rupto Chain Network

Add RPT to your wallet using https://faucet.ruptoscan.com/

Run this command in root of the project directory:

$ truffle migrate --network Rupto 

Contract will be deployed on Rupto Testnet, it look like this:

2_deploy_contracts.js
=====================

   Replacing 'MyContract'
   ------------------
   > transaction hash:    0xc921b127afd0ff2e1e5127367dbaa10cb79f019a22749dd651fc339fb361171e
   > Blocks: 10            Seconds: 2
   > contract address:    0xF0B2F5AbE5A52B5BF85B2320A730D1Ed714c1af3
   > block number:        11578
   > block timestamp:     1287126898
   > account:             0x384E2C3a9354EB3590F4e0789c9B800a7456fbe8
   > balance:             5 RPT
   > gas used:            1896986
   > gas price:           5 gwei
   > value sent:          0 RPT
   > total cost:          0 RPT

   Pausing for 2 confirmations...
   ------------------------------
   > confirmation number: 5 (block: 11585)
initialised!

   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:                   0 RPT


Summary
=======
> Total deployments:   3
> Final cost:          0 RPT

Remember your address, transaction_hash and other details provided would differ, Above is just to provide an idea of structure.

Congratulations! You have successfully deployed HelloRupto Smart Contract. Now you can interact with the Smart Contract.

You can check the deployment status here: https://faucet.ruptoscan.com/

Last updated