Running Ethereum Applications On NEAR
The major part of this work was done by James Prestwich and Barbara Liau from https://summa.one/.
TLDR: Today we are releasing a set of tools to deploy EVM contracts on the NEAR network, thus benefiting from the performance, user experience and developer tooling of NEAR. Underneath, it’s implemented as an execution environment which runs Ethereum as a smart contract on NEAR. Web3.js tooling works with NEAR via a custom provider.
EVM support and web3.js provider
Ethereum’s developer community is large, and many crypto developers are familiar with the Ethereum Virtual Machine (EVM). Solidity, an EVM-targeted language, has been developed since the beginning to serve as the primary language for smart contracts. While it has clear limitations when compared to general purpose languages like Rust and TypeScript, Solidity maintains broad adoption and extensive tooling for on-chain development.
NEAR, on the other hand, uses the WebAssembly Virtual Machine (WASM), an increasingly popular technology both in crypto and in the wider tech world. The majority of the crypto space is moving in this direction, with projects like ETH2, Polkadot, and more deciding to use WASM.
While we believe strongly in WebAssembly, we recognize the need to simplify this transition for developers, and are releasing a way for existing EVM contracts to run on NEAR. To do so, we’ve deployed the EVM as a smart contract. Conveniently, the Parity Ethereum client has an EVM implementation in Rust that is easily compilable to WebAssembly.
Running the EVM as a smart contract is essentially a simplified version of the ETH2 / Serenity execution environment concept, and it doesn’t require any custom transaction processing logic! You can find the EVM contract on Github.
Since the majority of Ethereum tooling relies on web3.js, we’ve implemented a custom web3 provider, NearProvider, that allows direct communication to Ethereum contracts via familiar interfaces in near-web3-provider library. NearProvider handles the connection to the Near network, and automatically translates objects and RPC calls for you.
Let’s dig in!
How it works
First, let’s get your Solidity application running on NEAR’s TestNet:
If you don’t have an existing Truffle project, set it up first. You can find the example here – https://github.com/kcole16/near-evm-demo.
Next, install NEAR shell:
npm install -g near-shell
Then, login with NEAR wallet:
near login
This will redirect you to the NEAR web wallet, and walk you through creating a new account. You can enter any accountID you’d like to use going forward. Next, you will authorize the CLI to use this account via a transaction, and then enter the newly created accountID to complete the login.
The next step is to configure NEAR as another network in truffle.js:
The above code imports near-web3-provider, which provides a mapping from Ethereum RPCs to NEAR’s network.
Next, we’ll point it to the keyStore that contains your NEAR account, from which you will be deploying applications (and paying fees). Here, I use my account illia, but you should change this to your accountId.
And that’s it, you are ready to deploy applications to NEAR’s EVM!
truffle migrate –network near
You can checkout success of your transaction in the block explorer: https://explorer.nearprotocol.com
The final step is to plugin your near-web3-provider into your frontend web3 code. This way you can now use NEAR Wallet and enable people to onboard and use your application easily.
Once you have your provider set up, you can interact with near-evm using Truffle, Web3.js, and many other standard Solidity development tools. While the library is still in early stages, many web3-based apps will just work out of the box.
You can checkout full example here: https://github.com/kcole16/near-evm-demo
NEAR EVM support is ready for your project! Start developing today.
Resources
Here are the useful resources:
- https://github.com/kcole16/near-evm-demo – repo with full demo.
- https://github.com/nearprotocol/near-evm – EVM execution environment contract.
- https://github.com/nearprotocol/near-web3-provider – NearProvider for Web3.js.
- https://t.me/joinchat/F3YJ0lcCcZka_GN09MGwJw – Developer support channel on Telegram for real time questions.
- https://commonwealth.im/near – forum for ideas and suggestions.
Share this:
Join the community:
Follow NEAR:
More posts from our blog
![](https://pages.near.org/wp-content/uploads/2024/02/acct-abstraction-blog-1-1024x512.png)
![](https://pages.near.org/wp-content/uploads/2024/02/acct-abstraction-blog-1-1024x512.png)
![](https://pages.near.org/wp-content/uploads/2024/08/redacted-2-blog-1024x512.png)
[REDACTED] Speakers Announced, Hackathon Registration Is Live