Welcome to Hoken Tech
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, the technical limit of it came to light, making many doubt its sustainability in the long term.
And as happened previously with Bitcoin that was technically limited and there were people and projects that started developing other ideas for performant blockchains like Ethereum, so between 2016 and 2017, other people began developing other ideas and consensus algorithms for further performant blockchains, and one of these was precisely the EOS blockchain, which thanks to its innovative consensus system, DPoS, demonstrated its technical superiority over other solutions, copied also by other projects and blockchains.
Other projects, instead of completely innovating, put the Ethereum structure at the base but 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 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 also 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.
Instead, the EOS blockchain, which by its very technical nature is not natively compatible with Ethereum and the related EVM, had to develop something that did not exist and of incredible technical difficulty, namely emulate the EVM within the EOS blockchain.
That's right, run the Ethereum blockchain within the EOS one through a smart contract, something that is technically challenging as a technically evolved and performant blockchain is also needed, just like EOS, something impossible on Ethereum, i.e. emulate EOS on the Ethereum blockchain.
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:
Definitely 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):
Now there remains to actually deploy to the blockchain and now let's move to the last menu "Deploy & Run Transactions", and in the "Enviroment" section we choose the option "Injected Provider - MetaMask", and automatically it will take in input the EOS EVM (or testnet or mainnet that we have chosen), and we should now click the "Deploy" button and confirm the transaction with the MetaMask wallet:
And here we are, in less than 5 minutes we have migrated our smart contract to the EOS EVM.
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 made by Hoken Tech's CTO Alfredo, where he illustrates the various steps:
nft, hoken tech, blockchain, cryptoart, eos, nft art, artificial intelligence, ai, watch authentication, crypto artist, nfts, web3, nft game, web3 game, videogame, nft distributor, videogame blockchain