How to Deploy Smart Contract on StratoVM Testnet Using Remix, Step-by-Step Guide

Stratoswap Finance
5 min readJun 23, 2024

--

Remix IDE

Deploying a smart contract on StratoVM Testnet is straightforward with Remix, an online IDE for Ethereum and EVM-compatible blockchains. Remix is a web-based application, so to use it, all you need is an internet connection and access to a web browser. To access Remix IDE, visit https://remix.ethereum.org.

We’ll write a basic ERC-20 smart contract from scratch, deploy it using Remix, and mint 1,000,000 tokens to the deployer’s address.

You need to configure your MetaMask to connect to the StratoVM Testnet by following the tutorial here.

You also need to have StratoVM BTC Testnet tokens to deploy your smart contract. Claim tokens from the faucet by following the tutorial made by the StratoVM team here.

This guide will walk you through deploying a simple ERC-20 token on the StratoVM Testnet.

Step 1: Access Remix

  1. Open Remix: Visit Remix.

2. Create a new file: In the file explorer on the left, click the “+” icon to create a new file. Name it TestToken.sol.

Step 2: Write the ERC-20 Smart Contract

Copy and paste the following code into TestToken.sol:

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

contract MyToken {
string public name = "Test Token"; //Change it with your desired token name
string public symbol = "tTKN"; //Change it with your desired token symbol
uint8 public decimals = 18; //Change it with your desired token decimals
uint256 public totalSupply;
address public owner;

mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;

event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);

constructor() {
owner = msg.sender;
totalSupply = 1000000 * 10 ** uint256(decimals); // Change 1000000 with your desired token supply
balanceOf[owner] = totalSupply;
emit Transfer(address(0), owner, totalSupply);
}

function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value, "Insufficient balance");
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
emit Transfer(msg.sender, _to, _value);
return true;
}

function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= balanceOf[_from], "Insufficient balance");
require(_value <= allowance[_from][msg.sender], "Allowance exceeded");
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
allowance[_from][msg.sender] -= _value;
emit Transfer(_from, _to, _value);
return true;
}
}

Step 3: Compile the Smart Contract

  1. Select the Solidity compiler: On the left panel, click the “Solidity Compiler” tab (third icon from the top).
  2. Set the compiler version: Choose version 0.8.0 or higher from the dropdown.
  3. Compile: Click the “Compile TestToken.sol” button. Ensure there are no errors.

Step 4: Deploy the Smart Contract

  1. Open the Deploy & Run tab: Click on the “Deploy & Run Transactions” tab (fourth icon from the top).
  2. Select the environment: Choose “Injected Provider — MetaMask” from the Environment dropdown. This will prompt MetaMask to connect to Remix.
  3. Connect MetaMask: Approve the connection request in MetaMask.
  4. Configure the network: Ensure that MetaMask is set to the StratoVM Testnet.
  5. Deploy: Click the “Deploy” button next to TestToken under the "Deployed Contracts" section.

Step 5: Confirm Deployment in MetaMask

  1. Transaction confirmation: MetaMask will prompt you to confirm the deployment transaction.

2. Gas fee: Review and confirm the gas fee.

3. Wait for deployment: Wait for the transaction to be confirmed on the StratoVM Testnet. You will see the contract under “Deployed Contracts” in Remix once it’s deployed.

Step 6: Verify the Deployment

  1. View the contract: After deployment, expand the contract in Remix under the “Deployed Contracts” section.
  2. Interact with the contract: You can now interact with the smart contract functions like name, symbol, totalSupply, and balanceOf.

Use the balanceOf function in Remix to check the deployer’s balance. It should show 1000000 tokens, adjusted for decimals.

Step 7: View in Metamask

You can add the token to MetaMask to see your balance.

  1. Click “Import Tokens” in MetaMask.
  2. Enter the contract address of the deployed token.

3. MetaMask should automatically fill in the token details.

Congratulations! You have successfully deployed an ERC-20 token on the StratoVM Testnet using Remix.

This basic example shows how StratoVM can be leveraged to create and manage tokens with the security and scalability of Bitcoin’s Layer 2. Explore more complex functionalities and dApps to harness the full potential of StratoVM!

What’s Next?

You can add liquidity on our dex by visiting this link StratoSwap.

After you add liquidity, you can start trading your very own token.

Explore StratoSwap: Website | dApp | Discord | Twitter | Docs | Medium

--

--