Deploy a DApp


Let's use 5-10 minutes to deploy a complete game through ThunderCore that is easily accessible to your own friends and family -- accessible to anyone with internet access. We will release a simple coin toss game where players will receive twice as many bets if the coin is facing up. In the case of coins facing down, players will lose their bets, but still have a chance to double the bet.

Exploring the Game

To begin, we will obtain a wallet and gain access to the Thunder network. With either Metamask or TrustWallet pointed to the Thunder RPC, navigate HERE to play the game we will build in this tutorial!

To make your own version of the page, just check out the repo and follow the instructions in the readme.

At the end of those instructions, you should be able to access the game with either your mobile device through Metamask or any ThunderCore compatible mobile DApp browsers.

Deploying Your Own Contract

Now, let's get your game running on your own copy of the contract, so you can get started developing your own killer DApp!

First we will install all the dependencies.

node -v
# Let's make sure our node is v8 or v10

If you haven't downloaded node.js, go to node.js download the version 8 or version 10. If you have downloaded it before but your version is incompatible, install it with nvm, and follow the instructions below.

nvm install [v8 or v10]
nvm use [v8 or v10]

node -v  #Make double check our node is v8 or v10 (recommend node version:10.24.1)
cd ./smart-contracts
yarn install

# or
npm install

Next grab your mnemonic or import your private key from metamask and create a file called .private-keys under “./smart-contracts ” or Trust Wallet and add it to the HDWallet in truffle-config.js

yarn migrate --network thunder-testnet --reset
# or
npm run migrate -- --network thunder-testnet --reset
yarn migrate --network thunder-mainnet --reset
# or
npm run migrate -- --network thunder-mainnet --reset

In the console, you will see the price you've paid for its deployment, the contract address, and additional stats. Well done! Your contract is now up and running ready to be used by anyone. If the contract address of DoubleOrNothing didn’t show up in the console after the migration ,you can check the contract address by typing the command below.

$ Truffle console --network thunder-mainnet
$ Truffle console --network thunder-mainnet

let contract = await DoubleOrNothing.deployed()

To make sure you've deployed doubleOrNothing smart contract successfully,you can double check the contract address and contract block number you've deployed lately.


truffle(thunder-testnet)>let contract = await DoubleOrNothing.deployed()
truffle(thunder-testnet)> DoubleOrNothing.address
truffle(thunder-testnet)> n = web3.eth.getBlockNumber();


truffle(thunder-mainnet)>let contract = await DoubleOrNothing.deployed()
truffle(thunder-mainnet)> DoubleOrNothing.address
truffle(thunder-mainnet)> n = web3.eth.getBlockNumber();

We must now update our UI to use this contract address.

cd ./frontend
yarn install
# or
npm install

Find the .env file and change the REACT_APP_CONTRACT_ADDRESS to your new address which you got by the command DoubleOrNothing.address above.

Meanwhile, you can start by deploying on testnet , change 'REACT_APP_TT_USDT_CONTRACT(testnet)' to 0xB1Fb0b14Ffea209ABa1e62ff3F2F3DFD2eaa9FE0, and comment out another REACT_APP_TT_USDT_CONTRACT address. If you’re not sure of the REACT_APP_TT_USDT_CONTRACT testnet or mainet address, check out on thundercore bridge.

Below are the specific steps we mentioned above.

First of all, click on the option above.Next, click the info symbol below.

You can see the TT-USDT ADDRESS ,which is REACT_APP_TT_USDT_CONTRACT=0xB1Fb0b14Ffea209ABa1e62ff3F2F3DFD2eaa9FE0

yarn start
# or
npm run start

This will start a local server with your changes. If you want to deploy this to your webpage run:

yarn build
# or
npm run build
git add -u

*Remember to not check in your mnemonic!!!!
git commit -m 'add my own contract address'
git push

Voila! In 5-10 seconds, your webpage will be running on your contract.Congratulations!


Add a Console to display an Error Message in the DApp's UI when running in the Wallet tab of TT Wallet to display any error messages for problems/errors encountered while interacting with the chain.

Example 1: TT20 Transactions

Example 2: DoubleOrNothing

Last updated