EVM in Velas

Velas native application model is aiming to high performance by spliting its modifiable state across multiple accounts. While this allows to process transactions in parallel on single shard, thats also introduce complication for ordinary DApps developer. Also, most of DApps infrastructure is already relies on Solidity, and targeting Ethereum blockchain. These two reasons can significantly slow down the spread of solana ecosystem.

To make life of DApps developers, and integrators more easier, we at Velas introduce full hybrid of solana and EVM.

Check out Velas address convention for detail how addresses will look in evm.

Metamask support

In our integration we support Metamask. In order to use it just follow metamask official instruction to add any public EVM Bridge as custom network.

Transfer native token to EVM

In order to transfer native token into EVM, we can use evm-utils binary. Note: EVM store tokens in nano lamports, so when you transfer for example, 5 lamports, your balance will be reported as 5*10^9

Usage:

> evm-utils transfer-to-eth --help
evm-utils-transfer-to-eth 0.1.0
Transfer solana token to EVM world
USAGE:
evm-utils transfer-to-eth <amount> <ether-address>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<amount> Amount in lamports
<ether-address> Address in evm, that will receive tokens

Example:

> evm-utils transfer-to-evm 5 0x9Edb9E0B88Dbf2a29aE121a657e1860aEceaA53D

Result after transaction processing:

[2020-12-26T15:03:01Z INFO evm_utils] Loading keypair from: /home/user/.config/solana/id.json
Transaction signature = 5d3eP741NYgemyM4CLmXuTEcP8f8w7QxfZ5vBxorqenEtNeSHWMFpkwtyi1meFKHVNXzDD3NbvFCExjZH79gEMKk

To make sure that balance was updated, you can request it using rpc:

curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x9Edb9E0B88Dbf2a29aE121a657e1860aEceaA53D", "latest"],"id":1}' -H "Content-Type: application/json" http://127.0.0.1:8899
{"jsonrpc":"2.0","result":"0x12a05f200","id":1}

0x12a05f200 is a hex representation of 5*10^9

For more information about rpc checkout evm-rpc page.

Transfer token from EVM back to native

For transfering tokens back to native chain, we have a special precompiled contract, that deployed at address:

0x56454c41532D434841494e000000000053574150

With following interface:

pragma solidity ^0.6.0;
interface TransferToNative {
function transferToNative(bytes32 native_recipient) virtual external payable;
}

native_recipient is 32byte address of Velas Native account. To swap tokens, one should create transaction on address 0x56454c41532D434841494e000000000053574150 with value specified in transaction. This transaction then can be sent to EVM Bridge, that will wrap it to native transaction.