Smart contract
W Chain utilizes the Ethereum Virtual Machine (EVM) in the backend. Smart contracts are written in Solidity and they can function on W Chain as they do on Ethereum. To deploy a smart contract, you send a transaction containing your bytecode without specifying any recipients. After the contract is deployed, it will be available to all users of the W Chain network.
You don't have to write and deploy your smart contract manually like that, there many tools or frameworks that will help you write, test and deploy your smart contracts in better ways.
Foundry
Foundry is an open-source, modern development framework designed for writing, testing, and deploying Solidity smart contracts for Ethereum and other EVM-compatible blockchains. Written in Rust, it offers a fast, efficient, and developer-friendly environment with tools like Forge for compiling, testing, and deploying contracts, Cast for interacting with the blockchain via the command line, and Anvil for running a local Ethereum node for testing.
Foundry emphasizes simplicity, speed, and modularity, allowing developers to write robust tests in Solidity, debug contracts easily, and integrate with existing Ethereum tools. Its focus on a test-driven development approach and seamless integration with Git makes it a popular choice for building secure and scalable decentralized applications.
We recommend Foundry, as it natively use Solidity in its scripting, testing and deploying functionalities. You will never need to switch between different programming languages, use Solidity everywhere!
Here is the recommended settings for your foundry.toml
:
Using this settings, you will be able to use the RPC in your CLI commands. Here are some examples:
Hardhat
Hardhat is an open-source, flexible, and extensible development environment for writing, compiling, testing, and deploying Solidity smart contracts for Ethereum and EVM-compatible blockchains. Built with JavaScript and Node.js, it provides a robust framework for developers to create, debug, and deploy smart contracts efficiently.
Key features include the Hardhat Network for local blockchain testing, a powerful task runner for automating workflows, and support for plugins to extend functionality. Hardhatβs intuitive API, detailed error reporting, and integration with tools like TypeScript and Ethers.js make it ideal for both beginners and experienced developers building secure, scalable decentralized applications.
Compared to Foundry, Hardhat will require you to switch contexts between Solidity and Javascript/TypeScript. This benefits developers with good Javascript background as it will use familiar testing modules, and share same contexts with Ethers JS, building early connection to UI/Frontend side of the dApp.
Here is a settings you can start from:
Verifying Smart Contract
We recommend you to use Foundry or Hardhat to build, deploy and to verify the source code on W Chain Block Explorer. If there's any situation you want to manually verify a smart contract, you can send the POST request to W Chain Block Explorer's API. Here's an example:
It's very important to ensure the exact code format, source code, compiler version, constructor arguments (if any), optimizations configs and EVM version.
Last updated