Call EVM From WASM
Last updated
Last updated
This guide will walk you through the process of calling EVM contracts from the WASM code e.g., Rust.
Before you begin, ensure you have the following:
Git: Used for code management and obtain examples.
Rust: Install it from .
Pharos Devnet/Testnet Access: Access to a Pharos node (local or remote) for interacting with the blockchain.
Install the pharos wasm toolchain plugin using the Cargo tool:
Add the wasm32-unknown-unknown
build target to your Rust compiler:
You should now have it available as a Cargo subcommand:
Note: Pharos built the chain excution client from scratch using C++, and we design, developed and open-sourced the VM, which combines EVM and WASM in a deeply compiled VM arch with native interoperability. The Rust toolchain and Rust SDK are forked from Stylus toolchain and SDK to facilitate easier adoption, the change here is the removal of Arbitrum ink billing and the simplification of the activation and compilation process on Pharos.
Clone the example repo:
Create a new file for your interoperability contract:
Write the interoperability Contract:
Open src/lib.rs
in your favorite text editor and add the following code:
Compile the Smart Contract:
Use cargo to compile the contract:
Contract Deployment Fails: Ensure you have enough testnet tokens to cover the deployment cost.
Interaction Issues: Verify that the contract address and ABI are correct.
Insufficient Balance: Ensure your wallet has enough tokens to transfer.