Skip to main content

Simple Smart Contract

This tutorial shows step by step how to use Remix and Metamask, which are tools that were originally built for Ethereum, to create and deploy a simple smart contract on Velas EVM.

Get coins for testing - Airdrop instruction

Smart contract sample:

pragma solidity >=0.4.22 <0.7.0;


contract HelloWorld {
function sayHello() external pure returns (string memory) {
return 'Hello World';
}
}

Compile contract

  1. Go to Remix
  2. In the home page choose environment "Solidity" ans create new file "Hello_World.sol"
  3. Insert contract code and compile

Connect Metamask to public bridge-rpc

To connect your metamask account to Velas public bridge-rpc:

  1. Open Metamask and go to networks
  2. Custom RPC
Network Name:
Velas Testnet

New RPC URL:
https://explorer.testnet.velas.com/rpc

ChainID (optional):
111

Connect Metamask to local node

To get info about running your node check "Bridge to EVM" section. By default bridge runs on port 8545.

To connect your metamask account to local bridge:

  1. Open Metamask and go to networks

  2. Custom RPC

    Network Name:
    Velas Testnet

    New RPC URL:
    https://localhost:8545

    ChainID (optional):
    111

By default, node runs on 8545 port. Can be changed if node uses different port for bridge.

Deploy

  1. Open Remix
  2. On the left side panel choose "Deploy and run transactions" section
  3. Choose environment "Injected Web3" to connect metamask account
  4. Choose "Hello_World.sol" contract in dropdown menu
  5. Press deploy button
  6. Confirm on Metamask popup window

Test

Remix will add your contract instance on the same page for deploying. To test your code simply call "sayHello" method by pressing button in you new contract menu.