Ethereum flavored WebAssembly (Ewasm)

Ewasm is the next generation Ethereum virtual machine.

The Ewasm is the future of Ethereum smart contracts and applications. It is highly-efficient, supported by the mainstream tech communities, and could support more programming languages on the frontend.

Step 1 Compile your smart contract to WebAssembly bytecode

Here is a simple ERC20 smart contractarrow-up-right written in Solidity. Compiling it with the Second State SOLL compilerarrow-up-right, you will get a WebAssembly bytecodearrow-up-right file. Then, convert it to HEX textarrow-up-right so that we can deploy via web3 JavaScript.

Step 2 Deploy the contract via web3

The Node.js application deploy_contract.jsarrow-up-right deploys the ERC20 smart contract to the mainnet node. It uses the HEX bytecode from SOLL, as well as the private key from a known address to pay for "gas", and then initiate a coin transfer transaction.

$ node deploy_contract.js

Web3 is connected.
accounts: ["0x1BbE5edc5Caabf4517e40b766D64c3DEd86822Df"]
Contract created at 0x984718904f853A004F145d133dEAb0c1dE50466B
contract.balanceOf(0x1BbE5edc5Caabf4517e40b766D64c3DEd86822Df) = 1000

Step 3 Make an ERC20 coin transfer

The Node.js application transfer_erc20.jsarrow-up-right makes a transfer from the ERC20 contract we just created. It transfers from the contract creator's address, which we know the private key of, to another address, and then prints the balance. The first argument is the ERC20 contract address, the second argument is the TO address that receives the ERC20 tokens, and the third argument is the amount of ERC20 tokens to transfer.

This is just a taste of the future. As Ewasm evolves, we will see many more smart contracts and dapps written in WebAssembly in the future.

Last updated

Was this helpful?