Run an ewasm smart contract

Next generation Ethereum smart contracts at your finger tip

One of the key features of the Second State DevChain is its support for the next-gen Ethereum virtual machine, Ewasm. Smart contracts compiled to Ewasm can be deployed on the DevChain.

Run a ERC20 EWASM smart contract now!

You can use the SOLL compiler to compile Solidity or YUL source code to Ewasm bytecode. Follow the instructions here. The Solidity source code the smart contract is as follows. It is a simplified ERC20 contract.

The compiled ewasm bytecode is converted to text using the xxd tool.

Now, let's prefix the ewasm code with 0x and deploy it to the blockchain from the default coinbase address. Recall that the default passphrase for the coinbase is 1234. All you need is an address that has some CMTs in it.

Note the return value from the sendTransaction is the transaction hash. We can use it to find the address of the newly created contract.

Next, create an instance of this contract at the above address. You will need the ABI for this contract (based on the Solidity source code) for this to work. Then, we can query the account balances in this ERC20 token contract. The creator address of this contact has all the initial supply of the tokens, and everyone else is zero.

Finally, we can make transfer calls on the contract to transfer ERC20 tokens between accounts.

That's it. You have now deployed and executed an ewasm smart contract on a real blockchain. Welcome to the future of Ethereum!

Last updated

Was this helpful?