ThunderCore
ThunderCoreThunderCore Bridge
  • ⚡Hello world
  • Developer Program
  • Network Details
    • ThunderCore Mainnet
    • ThunderCore Testnet
    • Token List
    • Smart Contract Services
    • Full Node Deployment
  • Develop on ThunderCore
    • Migrate from Ethereum
    • Using Foundry
    • Using Hardhat
    • Using Remix
    • Using Truffle
    • Deploy TT20
    • Deploy a DApp
    • Deploy a NFT
  • Develop on TT Wallet
    • DApp Submission
    • Deeplinking
    • Signing Messages
    • Ethereum Provider API
    • Token Listing
    • Advertising with TT Wallet
      • Logo size submission guideline
      • Promotional Package
      • How we help developers
    • Developer Build - TT Wallet (Android)
  • FAQs
  • Product / Protocol
    • Wallets
      • MetaMask
        • Create a MetaMask Wallet
        • Create multiple accounts
      • TT Wallet
    • ThunderCore Bridge
      • Architecture
      • Ethereum <> ThunderCore
      • BNB chain <> ThunderCore
      • Interact with ThunderCore Bridge
  • Tool
    • Game Development
      • MetaFab
    • DApp Development
      • Faucet
      • Random Number Generator
      • Oracles
      • Referral Library
      • TTSwap Resources
      • Wrapped TT Addresses
      • Multicall
      • Subgraph
      • Auth Service
      • Wallet Service
      • Node Service
Powered by GitBook
On this page
  1. Develop on ThunderCore

Using Truffle

Last updated 1 year ago

Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier.

Adding Truffle to your project

You'll need installed before we get started. And you can choose a preferred package management tool to begin with:

# To use truffle locally in your project, you must init a package.json file
$ npm init

# Install truffle and wallet-provider to your project
$ npm i -D truffle @truffle/hdwallet-provider

# Generate truffle configuation file and default folders
$ npm exec -- truffle init
# To use truffle locally in your project, you must init a package.json file
$ yarn init

# Install truffle and wallet-provider to your project
$ yarn add --dev truffle @truffle/hdwallet-provider

# Generate truffle configuation file and default folders
$ yarn truffle init

You can install global Truffle to your environment:

$ npm i -g truffle

Then, you can ignore npm exec -- or yarn commands before truffle

Setup Truffle config file

We are going to edit truffle-config.js. First, we uncomment this line to import @truffle/hdwallet-provider:

truffle-config.js
- // const HDWalletProvider = require('@truffle/hdwallet-provider');
+ const HDWalletProvider = require('@truffle/hdwallet-provider');

Then, we add ThunderCore network settings into your project.

truffle-config.js
networks: {
  "thunder-mainnet": {
    provider: () => new HDWalletProvider([process.env.KEY], "https://mainnet-rpc.thundercore.com"),
    network_id: "108",
    gas: 90000000,
    gasPrice: 15e9
  },
  "thunder-testnet": {
    provider: () => new HDWalletProvider([process.env.KEY], "https://testnet-rpc.thundercore.com"),
    network_id: "18",
    gas: 90000000,
    gasPrice: 15e9
  }
}

Never store your private key directly in truffle-config.js

Deploy a Contract

Now, we can deploy the Migrator contract in the template to ThunderCore testnet.

# Using NPM
KEY=0xPrivateKey npm exec -- truffle migrate --network thunder-testnet --reset
# or using Yarn
KEY=0xPrivateKey yarn truffle migrate --network thunder-testnet --reset
# Using NPM
set KEY=0xPrivateKey & npm exec -- truffle migrate --network thunder-testnet --reset
# or using Yarn
set KEY=0xPrivateKey & yarn truffle migrate --network thunder-testnet --reset
# Using NPM
$env:KEY='0xPrivateKey';npm exec -- truffle migrate --network thunder-testnet --reset
# or using Yarn
$env:KEY='0xPrivateKey';yarn truffle migrate --network thunder-testnet --reset

When it's done, should show messages like this:

Starting migrations...
======================
> Network name:    'thunder-testnet'
> Network id:      18
> Block gas limit: 100000000 (0x5f5e100)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

   ...
   ...
   ...

   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:         0.000266154 ETH


Summary
=======
> Total deployments:   1
> Final cost:          0.000266154 ETH

Congratulations! You have successfully deployed a smart contract onto the ThunderCore network.

You can check the deployment status at:

You'll need gas tokens to deploy contracts. To test on ThunderCore testnet, you can get testnet tokens from

Node.js v8+
ThunderCore testnet Faucet
ThunderCore mainnet:
ThunderCore testnet: