Developer Documentation
  • What is CTEX?
  • Learn about CTEX Chain
    • Ctex Overview: vision, strategy and platform components
    • The Ctex Blockchain
      • Ctex Consensus Mechanism
      • Delegation and Staking with Validators
      • Ethereum (EVM) Compatibility and Smart Contracts
      • Boosting Ctex's Scalability
  • Empowering Global Payments with Ctex
  • Ctex Key Feature
  • Ctex Consensus
  • CTEX Clusters
    • CTEXChain Mainnet
    • CTEXChain Testnet
    • CLI Command
    • Ctex Faucet
    • Audit Report
  • Integrating with Metamask
    • Add Ctex Chain Network to Metamask
    • Config Custom Token
    • How to Reset Metamask Wallet
  • CTEX Exclusive Product
  • Ctex Coin
    • Technical
    • Utility
    • Distribution
  • Run Master Node
  • Developer Guide
    • Token Standard
      • CTEX-721 Token
      • CTEX-20 Token
  • APIs
    • accounts
    • blockNumber
    • call
    • chainId
    • estimateGas
    • gasPrice
    • getBalance
    • getBlockByHash
    • getBlockByNumber
    • getBlockTransactionCountByHash
    • getBlockTransactionCountByNumber
    • getCode
    • getLogs
    • getStorageAt
    • getTransactionByBlockHashAndIndex
    • getTransactionByBlockNumberAndIndex
    • getTransactionByHash
    • getTransactionCount
    • getTransactionReceipt
    • getUncleByBlockHashAndIndex
    • getUncleByBlockNumberAndIndex
    • getUncleCountByBlockHash
    • getUncleCountByBlockNumber
    • getWork
    • hashrate
    • mining
    • protocolVersion
    • sendRawTransaction
    • submitWork
    • syncing
    • net_listening
    • net_peerCount
    • net_version
    • web3_clientVersion
    • parity_nextNonce
    • Filter methods
    • newFilter
    • newBlockFilter
    • getFilterChanges
    • uninstallFilter
  • Depolying CTEX chain
    • Using Remix
    • Using Truffle
    • Using Hardhat
    • Using Replit
    • Using Alchemy
  • Whitepaper
  • Technical Paper
  • Yellow Paper
Powered by GitBook
On this page
  1. Depolying CTEX chain

Using Truffle

PreviousUsing RemixNextUsing Hardhat

Last updated 1 year ago

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

  • (comes with Node)

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

Copy

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 by truffle, To setup the truffle environment.

truffle-config

  • Go to truffle-config.js

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

Copy

Explainconst 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)
    },
    ctex : {
      provider: () => new HDWalletProvider(mnemonic, `https://testnet-rpc.ctexscan.com`),
      network_id: 74152,
      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 CTEX 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 ctex Chain Network

Run this command in root of the project directory:

Copy

$ truffle migrate --network ctex

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

Copy

Explain2_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 CTEX
   > gas used:            1896986
   > gas price:           5 gwei
   > value sent:          0 CTEX
   > total cost:          0 CTEX

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

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


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

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 Helloctex Smart Contract. Now you can interact with the Smart Contract.

Add IGT to your wallet using

You can check the deployment status here:

Node.js v8+ LTS and npm
Git
Getting Started
https://faucet.ctexscan.com/
https://testnet-rpc.ctexscan.com