Skip to content

Using Remix to Deploy to Your Tanssi EVM Network

Introduction

Developers building dApps on top of Tanssi-powered EVM networks can use Remix, one of the most popular Ethereum development environments, to build, compile, and deploy their smart contracts. Remix can be used with any EVM network, thanks to the seamless compatibility of Tanssi-powered EVM networks.

This guide walks through the process of creating and deploying a Solidity-based smart contract to the Tanssi Dancebox TestNet using the Remix IDE. This guide can be adapted for your own Tanssi EVM network by simply adding the RPC URL of your network to your EVM Wallet and switching networks to it.

Checking Prerequisites

For this guide, you'll need to have MetaMask installed and configured to work with your Tanssi EVM network. You can follow this guide to configure MetaMask for Tanssi with the demo EVM network.

Getting Started with Remix

Now, you can head to Remix to get started. On the main screen, navigate to the File Explorer tab.

File explorer

Next, you can create a new file to save the Solidity smart contract. To do so, take the following steps:

  1. Press the Create New File button on the left-hand side of File Explorer
  2. Enter your desired filename, such as MyToken.sol

Create a new file for your Solidity contract

Next, paste the following smart contract into the editor tab:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/audit/2023-03/contracts/token/ERC20/ERC20.sol';

// This ERC-20 contract mints the specified amount of tokens to the contract creator.
contract MyToken is ERC20 {
  constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") {
    _mint(msg.sender, initialSupply);
  }
}

Paste the contract into the editor

This is a simple ERC-20 contract based on the current OpenZeppelin ERC-20 template. It creates MyToken with symbol MYTOK and mints the entirety of the initial supply to the creator of the contract.

To compile your smart contract, take the following steps:

  1. Navigate to the Solidity compiler tab
  2. Press the Compile MyToken.sol button

Compile MyToken.sol

Your contract is now compiled and ready to be deployed to your Tanssi network.

Deploying a Contract to Your Network Using Remix

Now you can deploy the contract by navigating to the Deployment sidebar option. You need to change the topmost ENVIRONMENT dropdown from JavaScript VM to Injected Web3. This tells Remix to use the MetaMask injected provider, which will point it to your Tanssi-powered EVM network, so long as the selected network in your MetaMask is your Tanssi EVM network. If you need to change your network in MetaMask, you can easily do so, and Remix will update your account balances to reflect the network change.

Change environment to injected Web3

As soon as you select Injected Web3, you will be prompted to allow Remix to connect to your MetaMask account. Then, take the following steps:

  1. Select the account(s) that you would like to use with Remix
  2. Press Next
  3. Press Connect

Select accounts to connect to Remix

Back on Remix, you should see the account you wish to use for deployment is now managed by MetaMask. To deploy your token contract, take the following steps:

  1. Next to the Deploy button, specify an initial supply of 8 million tokens. Since this contract uses the default of 18 decimals, the value to put in the box is 8000000000000000000000000. Once you have entered this value, press Deploy
  2. Confirm the contract deployment transaction in MetaMask.

Enter an token balance and deploy

After you press Confirm and the deployment is complete, you will see the transaction listed in MetaMask. The contract will appear under Deployed Contracts in Remix. You can access the address of the deployed contract by pressing the copy button.

Confirmed label on a transaction

Once the contract is deployed, you can interact with it from within Remix. To familiarize yourself with interacting with a smart contract from Remix, take the following steps:

  1. Expand the contract under the Deployed Contracts section
  2. Paste in your address (the address that deployed the token contract) next to the balanceOf method and press balanceOf. You should see the entirety of the balance of the ERC-20 belonging to that address
  3. Press Decimals to see the number of decimal points the token has
  4. Press Name to see the name you assigned the token
  5. Press Symbol to see the token symbol
  6. Press Initial Supply and you should see 8000000000000000000000000
  7. Copy the contract address by clicking the button next to the contract name and address. You'll need it in the next section

Interact with the contract from Remix

Interacting with an ERC-20 on Your Network from MetaMask

Now, open MetaMask to add the newly deployed ERC-20 tokens. Make sure you are connected to the account that deployed the token contract. Additionally, make sure you have copied the contract's address from Remix.

To add the token to MetaMask, take the following steps:

  1. Click on the Tokens tab as shown below
  2. Press Import tokens

Add a token

Then, take the following steps:

  1. Paste the copied contract address into the Token contract address field. The Token symbol and Token decimal fields should be automatically populated
  2. Press Next

Paste the copied contract address

After clicking Next, you will need to confirm that you want to add these tokens to your MetaMask account. Click Import and you should see a balance of 8 million MyTokens in MetaMask:

Add the tokens to your MetaMask account

Now you can send some of these ERC-20 tokens to the other account that you have set up in MetaMask. Click Send to initiate the transfer of 500 MyTokens and select the destination account.

After clicking Next, you will be asked to confirm (similar to what is pictured below).

Confirmation of the token transfer

Click Confirm and, after the transaction is complete, you will see a confirmation and a reduction of the MyToken account balance from the sender account in MetaMask.

Verify the reduction in account balance

You can also look up the transaction on your Tanssi network's explorer to verify the transaction status.

Check transaction status on block explorer for your Tanssi network

The information presented herein has been provided by third parties and is made available solely for general information purposes. Tanssi does not endorse any project listed and described on the Tanssi Doc Website (https://docs.tanssi.network/). Tanssi Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Tanssi Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Tanssi Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Tanssi Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Tanssi Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
Last update: December 13, 2024
| Created: October 10, 2023