With the advent of the Ethereum blockchain and the possibility of creating smart contracts, several years ago, the Ethereum blockchain became, over time, the starting point for developers and projects to create new platforms and experiences previously unthinkable, such as video games, decentralized finance (DeFi) and more. At first, it seemed that Ethereum was the best blockchain to do everything, but little by little, and with the increasing number of projects and transactions, its technical limitations of it came to light, spurring doubts about its sustainability in the long term.
During the period between 2016 and 2017, as the limitations of Bitcoin became apparent, several individuals and projects started exploring alternative ideas for more efficient blockchains. This was similar to the situation when Ethereum emerged as a platform for building decentralized applications (dApps). In this context, one of the notable developments was the creation of the EOS blockchain.
Other projects, instead of completely innovating, put the Ethereum structure at the base by modifying other parameters, making them a theoretically faster and cheaper version of Ethereum.
Even if for non-professionals these blockchains are incredible, quite the opposite sentiment stems from a technical point of view, they had the advantage of being compatible with the EVM (Ethereum Virtual Machine), actually allowing those who had developed something on Ethereum to port it without too many problems on these new so-called "EVM compatible" blockchains.
As mentioned earlier, this type of blockchain allows you to use the same code created on Ethereum, which in this particular case is represented by a language created specifically called Solidity, where the file containing the instructions of the smart contract is in ".sol" format.
So for programmers, it was enough to use the same file, without even modifying it, to be able to use it on these EVM-compatible blockchains, and this has proved to be over time an essential function and characteristic to attract developers and also applications to the new blockchain.
Up to this point we have talked about blockchains that were born on the lines of Ethereum, but without really innovating the technological panorama. In fact, most of the EVM-compatible blockchains are almost identical to each other, and only the name of the token changes.
The EOS blockchain, not natively compatible with Ethereum and the EVM, had to develop a technically challenging solution to emulate the EVM within its ecosystem. Emulating the EVM on EOS required significant effort due to the differing architectures and consensus mechanisms of the two blockchains.
This emulation allowed EOS to run Ethereum-based dApps and execute Ethereum smart contracts within its ecosystem, providing developers with more options.
But despite everything, with the help of skilled engineers on EOS, the EOS EVM was born, launched in mid-April, demonstrating all its technical power also in comparison with other EVMs on other blockchains, and to do so the data that was chosen was precisely the "swap per second", surpassing by 4 times an EVM that until then was considered the fastest, namely the EVM on Solana.
Now that we have seen a bit of the history and functioning of the EVMs, it is time to get our hands dirty with the code and see how to migrate the code that we created for Ethereum, or another EVM blockchain, to the EOS EVM.
In order to migrate the smart contract we will need some things:
To deploy the smart contract, i.e. load the code onto the blockchain, we basically have 2 methods:
A quick method within everyone's reach is to use Remix, and from here we will deploy our smart contract.
First of all make sure that our MetaMask wallet is active on the EOS EVM, testnet, or mainnet, then connect to the Remix web interface, here, and create a new file giving it a name and the .sol extension:
Inside the empty file, we will paste our code; or if we have multiple smart contracts we can upload the files from our pc.
At this point, select the relative .sol file that we want to upload to the blockchain, and we move to the "Solidity Compiler" menu:
Here we will not have to do anything else but press the blue button and wait for the operation to be successful (just look at the green check mark):
In the final step of deploying to the blockchain, navigate to the "Deploy & Run Transactions" menu. Within the "Environment" section, select the "Injected Provider - MetaMask" option. This choice automatically takes into account the EOS EVM (whether it's the testnet or mainnet you've selected). Now, proceed by clicking the "Deploy" button. A prompt will appear, and you need to confirm the transaction using your MetaMask wallet.
And here we are, in less than 5 minutes we have migrated our smart contract to the EOS EVM.
Deploy with Hardhat
In case we developed our dApp using Hardhat, it will be enough to add the following networks to the "hardhat.config.js" configuration file:
Then run the command to deploy (remember that we should have some EOS on the address that will be used to cover the transaction costs):
Finally, in case of any error in using the dApp, specifically the error 32603 - MetaMask - RPC Error: Internal JSON-RPC error with message "gas required exceeds allowance":
It does not depend on a problem of the EOS EVM but from MetaMask, and the advice is to use another browser and redo the transaction, and the same will be processed without problems.
In conclusion, thanks to these simple operations, we can not only use our old code but also use a performant EVM, without end users having to install anything else since it is enough to add the new network and the related crypto.
Below is the video to illustrate the various steps: