Giter Site home page Giter Site logo

metacoin-box's Introduction

MetaCoin TronBox Example

Originally forked from truffle-box/metacoin.

Configure Network Information for TronBox

Network configuration is required by TronBox. In our case we use Tron Quickstart for local testing, and TroGrid for as testnet.

module.exports = {
  networks: {

// trontools/quickstart docker image
    development: {
          // For trontools/quickstart docker image
          privateKey: 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0',
          consume_user_resource_percent: 30,
          fee_limit: 100000000,
          fullHost: "http://127.0.0.1:9090",
          network_id: "9090"
        },
        shasta: {
          privateKey: process.env.PK,
          consume_user_resource_percent: 30,
          fee_limit: 100000000,
          fullHost: "https://api.shasta.trongrid.io",
          network_id: "2"
        }
  }
}

Use your own private network

tronbox migrate by default will use the development network that is set to use Tron Quickstart. In order to test the smart contracts and deploy them you must install Tron Quickstart.

  1. Install Docker.

  2. Run Tron Quickstart:

docker run -it --rm -p 9090:9090 --name tron trontools/quickstart

TronBox commands

tronbox compile
tronbox migrate --reset
tronbox test

The first time you execute a migration, the process can stuck. It is a know bug that we are trying to fix. Just Ctrl-c to stop the process. As you can verify, the contracts have been correctly deployed.

Run the example dApp on Shasta

  1. You need an account with some Shasta TRX. If you don't have any, open https://www.trongrid.io/shasta/ and require some Shasta TRX at the bottom of the page.

  2. Edit your tronbox.js and in the section shasta, set the privateKey of the account for which you requested Shasta TRX.

  3. Verify that your account is not empty opening a page like https://api.shasta.trongrid.io/wallet/getaccount?address=41559f48a697a006cfc35009cb059a400fc526b31f using, of course, your account address.

  4. Set the dApp. The dApp needs to know the address where the MetaCoin contract has been deployed. We have put in the box a special script:

npm run setup-dapp

It will execute the migration, retrieve the contract address and save it in the file src/js/metacoin-config.js.

  1. Run the dApp:
npm run dev

It automatically will open the dApp in the default browser.

  1. Enjoy your working Tron dApp!

metacoin-box's People

Contributors

sullof avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.