Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

GITBOOK-5: How to Migrate Dapps from Ethereum #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,78 @@ description: >-

# How to Migrate Dapps from Ethereum

Work In-Progress
As we previously went through deployment step [here](../smart-contract-development/ides-and-tools/hardhat.md). Change your hardhat configuration to match the following code.

```typescript
import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';

require('dotenv').config();

const config: HardhatUserConfig = {
solidity: {
version: '0.8.17',
},
networks: {
...
// for mainnet
'tomo-mainnet': {
url: 'https://rpc.tomochain.com',
accounts: [process.env.PRIVATE_KEY as string],
},
// for testnet
'tomo-testnet': {
url: 'https://rpc.testnet.tomochain.com',
accounts: [process.env.PRIVATE_KEY as string],
},
...
},
defaultNetwork: 'hardhat',
};

export default config;
```

To deploy the contract to the TomoChain, you'll need to modify the scripts/deploy.ts in your project:

{% hint style="info" %}
You should modify your deploy script in order to meet your contract's requirements. This is just an example to deploy Token contract previously presented [here](../smart-contract-development/ides-and-tools/hardhat.md).
{% endhint %}

```typescript
import { ethers } from 'hardhat';

async function main() {
const gasLimit = 100_000_000;
const myToken = await ethers.deployContract('MyToken', { gasLimit });

await myToken.waitForDeployment();

console.log('Token Contract Deployed at ' + myToken.target);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
```

Finally run your script with:

{% hint style="info" %}
Your account (with private key: `process.env.PRIVATE_KEY`) must have enough fund to deploy your contract.
{% endhint %}

* Tomo Testnet

```
npx hardhat run scripts/deploy.ts --network tomo-testnet
```

* Tomo Mainnet

```
npx hardhat run scripts/deploy.ts --network tomo-mainnet
```