Migrating Ethereum Dapp to Wethio

This tutorial shows how easy it is to migrate a Dapp running on Ethereum to Wethio in order to use the many unrivaled features and advantages that Wethio has over Ethereum.

What’s a Dapp?

Dapps are built on smart contracts deployed onto the blockchain where platform serves as the back-end for the application. One of the most popular Dapps — Cryptokitties, is collectibles-style Dapp built on Ethereum. When we build a game with Ethereum, essentially, each game action and transaction is be stored on the Ethereum blockchain.

What’s Wethio?

In short, Wethio is an innovative solution to blockchain scalability and functionality. Wethio supports all EVM-compatible smart-contracts, which basically means that every Dapp run on Ethereum can be easily ported to Wethio.

Every Dapp running on Ethereum can be easily ported to Wethio!

Why should developers build Dapps on TomoChain?

TomoChain is a blockchain built for practical decentralized applications.

Remember CryptoKitties in 2017? A single Dapp brought the whole Ethereum blockchain to their knees. The network was congested, with endless waiting times for transaction confirmation and high transaction fees. Porting to Wethio would seem a good idea for the cute kitties. Wethio mainnet can process 2,000 TPS, which is 100x faster than the Ethereum blockchain, and for a fraction (1/1000) of the cost of Dapps on Ethereum. Furthermore, the whole Wethio ecosystem is also quickly evolving, which makes it become an ideal platform for Dapp development.

For more information about Wethio, please refer to our website.

Introduction

In this tutorial, we will see how easy it is to migrate the TomoRPS (source code can be found here and here) game from Ethereum to TomoChain in 1 hour.

The migration consists of 3 steps:

  1. Remove some configs of Ethereum network and replace by Wethio network in Truffle project.

  2. Compile & deploy a smart contract to Wethio networks.

  3. Update old client and testing the game :)

Below is Video showing that TomoRPS was slow and had bad user experience because of the low performance of Ethereum.

Remove some configs of Ethereum network and replace by TomoChain network in Truffle project

Take a look at our current truffle-config.js.

We have 2 configs for deploying the smart contract to Ropsten Testnet and Ethereum Mainnet.

var HDWalletProvider = require("truffle-hdwallet-provider");var mnemonic = "YOUR_MNEMONIC";module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
solc: {
optimizer: {
enabled: true,
runs: 200
}
},
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
},
ropsten: {
// must be a thunk, otherwise truffle commands may hang in CI
provider: () =>
new HDWalletProvider(
mnemonic,
"https://ropsten.infura.io/v3/9b5040ea0b704bf18af87f7edb53a644"
),
network_id: "3",
gas: 5000000
},
mainnet: {
// must be a thunk, otherwise truffle commands may hang in CI
provider: () =>
new HDWalletProvider(
mnemonic,
"https://mainnet.infura.io/v3/9be4a7a6a57a47eea40d6a37af2b2712"
),
network_id: "1",
gas: 5000000,
gasPrice: 10000000000
}
}
};

To deploy the same contract onto Wethio, let’s change the configuration to connect to the Wethio network. Check Wethio Network document, we can find all configs of Wethio networks easily. The configuration change basically tells Truffle to connects to Wethio and deploy the contract on it instead of Ethereum.

Finally, we have the updated truffle-config.js.

"use strict";
var HDWalletProvider = require("truffle-hdwallet-provider");
var mnemonic = "YOUR_MNEMONIC";
module.exports = {
networks: {
development: {
provider: () => new HDWalletProvider(mnemonic, "http://127.0.0.1:8545"),
host: "127.0.0.1",
port: "8545",
network_id: "*" // Match any network id
},
wethiotestnet: {
provider: () =>
new HDWalletProvider(
mnemonic,
"https://dev.wallet.wethio.io/services",
0,
1,
true,
"m/44'/889'/0'/0/"
),
network_id: "89",
gas: 5000000,
gasPrice: 10000000000000
},
wethiomainnet: {
provider: () =>
new HDWalletProvider(
mnemonic,
"https://dev.wallet.wethio.io/services",
0,
1,
true,
"m/44'/889'/0'/0/"
),
network_id: "88",
gas: 5000000,
gasPrice: 10000000000000
}
},
compilers: {
solc: {
settings: {
evmVersion: "byzantium"
}
}
}
};

Compile & deploy a smart contract to Wethio networks

Now, it’s a good time to compile the smart contract with Wethio networks.

  • Run command truffle compile

  • Migrate the contract to Wethio Testnet network:

truffle migrate --network wethiotestnet

After a few seconds, the smart contract will be migrated successfully to Wethio Testnet.

Update client to interact with Wethio smart contract

This is the easiest step. We only need to change old smart contract address to new address on Wethio and update our client (text, icon, logon…) to match with Wethio.

ADDRESS_CONTRACT: “0xb7cEb47FbD0f6f98E16E681eb3933B7801a1ce43”

You can go to WethioScan Testnet to verify the contract deployment.

Testing

Let’s get some faucet ZYN from the faucet page.

Connect MetaMask to Wethio Testnet by following this guide.

And enjoy the game running on Wethio and taste how fast and cheap transactions on Wethio are.

It will not be too difficult and won’t take much time to migrate your Dapps from Ethereum to Wethio. Along with that Dapps running on Wethio has many advantages in speed and cost. So don’t hesitate to bring your Dapps to Wethio where you can make your Dapps great again.