Arweave Smart Contracts Now Support Solidity, Rust and C: Everything We Know About 3em
On the 3rd of January 2022, Verto Exchange, the leading decentralised exchange (DEX) on Arweave, announced the public release of 3em, a multi-language execution environment for Arweave Smart Contracts.
1/ Introducing 3em, a secure, supercharged, multi-language execution environment for SmartWeave contracts: https://t.co/nVHIea7wbj
A 🧵 on this new technology… 👇 pic.twitter.com/GFTwW12Y53
— Verto Exchange (@vertoexchange) January 3, 2022
Verto Exchange has been working with the developers at 3em to incubate and help bring this idea to life.
3em and Arweave
Smart contracts are, at their core, pieces of code that contain functions that live on an immutable blockchain. When the smart contract is called, this code runs and executes those functions that then return a transaction result depending on the nature of that smart contract, whether it be to send funds to another user, or create (mint) an NFT.
When it comes to Arweave, the smart contract standard that has been used up until today is called SmartWeave. SmartWeave was created by Sam Williams and the wider Arweave team. It uses a method called “Lazy Evaluation”.
Traditional smart contract systems work in a way were every node (computers running the base software of a blockchain that verify all transactions) on the blockchain will execute every transaction to verify their validity, rejecting any false or malicious transactions.
The way lazy evaluation works is different and quite simple. Instead of every node verifying all transactions, it leaves the verifying to the users of the smart contract itself. When a user interacts with the smart contract they validate all previous transactions on the smart contract, before adding their own transaction at the end of those ones. The next user that comes along will then again verify all past transactions including this previous one.
“(The SmartWeave standard) proved that smart contracts on a permanent data layer (the permaweb) were possible.”
This was part of a thread that Tate posted on Twitter regarding 3em.
1/ Today’s public release of 3em was beyond exciting.
A separate 🧵 on NONtechnical implications & where we see this going… https://t.co/mW1Mi0x51K
— Tate Berenbaum 🐘 (@TateBerenbaum) January 4, 2022
What happens when more programmers come in and want to use other languages? And what happens when they want to interact with smart contracts on Ethereum that are written in Solidity?
Some form of universal “translator” that would allow all these contracts and protocols written in different programming languages to communicate was needed. And this is the issue that 3em is addressing.
3em is a programming execution environment. As described on 3em’s website, it allows you to “Run SmartWeave contracts in a matter of seconds, with support for multiple langauges.” So let’s take a closer look at 3em.
Polyglot, secure, fast!
The word Polyglot derives from the Greek word “Πολύγλωσσος”. It means someone that can talk multiple languages. And this is in exactly what 3em does.
3em was also created with security in mind. As described above, SmartWeave uses lazy evaluation for its contracts. And with 3em these contracts can talk to other contracts on other chains. The 3em developers wanted to make sure that users could not inject malicious code in to the path of other smart contracts.
So the answer to this was to create a sandboxed environment for the execution of the smart contracts. Think of a sandboxed environment as a testing ground that doesn’t allow anything to leave before making sure it is safe.
The 3em developers also wanted to make sure that their tech was fast. It was built with optimisation in mind.
The issue they are addressing here is bigger than might initially come to mind. Due to the way lazy evaluation works, each interaction with the smart contract on SmartWeave means that the next user that comes along will have more transactions to evaluate before appending their own transaction to the list.
How 3em works and integrates in the development stack
readContract function which returns data in the same way as the current smartweave-js implementation but much faster.
Developers can deploy 3em-compatible contracts via the command line tool on the project’s GitHub. They’re identified by specific transaction tags, and by reading the MIME type 3em knows which language to parse as it reads. For developers, the exception comes when sending interactions to and reading from EVM bytecode contracts; instead of the usual JSON, the inputs and outputs will be encoded with Ethereum ABI.
For examples of 3em test transactions, check:
- VM contract: _233QEbUxpTpxa_CUbGi3TVEEh2Qao5i_xzp4Lusv8I
- JS contract: t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y-BPZgKE
- WASM contract: KfU_1Uxe3-h2r3tP6ZMfMT-HBFlM887tTFtS-p4edYQ
This is probably the biggest news that has hit the Arweave ecosystem as of lately – definitely the biggest SmartWeave devlopment since RedStone’s implementation.
Resisting the urge to retweet every post on this thread.
This is an incredible step forward for the SmartWeave ecosystem 🤯 https://t.co/RvEwnfsIj2
— Sam Williams 🐘 (@samecwilliams) January 4, 2022
The future looks bright for 3em and the entire Arweave and SmartWeave ecosystem at large. This move will most likely bring more developers in to the world of Arweave and smart contracts that live on the permaweb.
Any developers wanting to start using 3em can do so now by going to their GitHub page.