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
- Go to Remix
- In the home page choose environment "Solidity" ans create new file "Hello_World.sol"
- Insert contract code and compile
Connect Metamask to public bridge-rpc
To connect your metamask account to Velas public bridge-rpc:
- Open Metamask and go to networks
- 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:
-
Open Metamask and go to networks
-
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
- Open Remix
- On the left side panel choose "Deploy and run transactions" section
- Choose environment "Injected Web3" to connect metamask account
- Choose "Hello_World.sol" contract in dropdown menu
- Press deploy button
- 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.