Add Smart Contract Functionality¶
Introduction¶
When building your custom blockchain with the Polkadot SDK, you can add smart contract capabilities through specialized pallets. These pallets enable users to deploy and execute smart contracts, enhancing your chain's programmability and allowing developers to build decentralized applications on your network.
This guide covers three approaches to adding smart contracts to your blockchain:
pallet-revive: Modern unified solution supporting both PVM and EVM bytecode- Frontier: Ethereum compatibility layer for Polkadot SDK-based chains
pallet-contracts: Wasm smart contract support
pallet-revive¶
pallet-revive is the modern smart contract solution for Polkadot SDK-based chains. It provides a unified execution environment that supports both PVM and EVM bytecode through dual execution backends.
Core Components¶
Essential Pallet: pallet-revive provides the core smart contract execution environment with PVM and REVM backends.
RPC Adapter: pallet-revive-eth-rpc adds full Ethereum RPC compatibility for Ethereum tooling integration.
Supported Languages and Compilers¶
pallet-revive accepts smart contracts from multiple languages and compilation paths:
| Language | Compiler | Output Bytecode | Execution Backend |
|---|---|---|---|
| Solidity | resolc | PVM | PVM |
| Solidity | solc | EVM | REVM |
| Rust (ink!) | cargo-contract | PVM | PVM |
Any language that can compile to PVM bytecode and utilize pallet-revive's host functions (via pallet-revive-uapi) is supported.
How It Works¶
Dual Execution Model:
- PVM Backend: Executes PVM bytecode with native performance optimization.
- REVM Backend: Implements EVM bytecode for compatibility with existing Ethereum contracts, ensuring seamless migration.
Key Benefits¶
- Unified platform: Deploys both PVM-optimized and EVM-compatible contracts using a single pallet.
- Performance: PVM execution provides improved performance compared to the traditional EVM, leveraging the RISC-V architecture to map instructions to the CPU and requires little transpiling.
- Ethereum compatibility: Supports full integration with Ethereum tooling via RPC adapter.
Implementation Examples¶
See a real-world implementation in the Polkadot Hub TestNet in the Polkadot Fellows repository.
Frontier¶
Frontier is the Ethereum compatibility layer designed for maximum compatibility with the Ethereum ecosystem. It's the ideal choice when you need seamless integration with existing Ethereum tools, dApps, and infrastructure.
Integration Options¶
Frontier offers flexible integration depending on your compatibility needs:
EVM Execution Only¶
For basic EVM support using Polkadot SDK native APIs:
pallet-evm: Provides the core EVM execution environment.
This configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction.
Full Ethereum Compatibility¶
For complete Ethereum ecosystem integration with Ethereum RPC support:
pallet-evm: Integrates core EVM execution environment.pallet-ethereum: Emulates Ethereum blocks and handles Ethereum-formatted transactions.fc-rpc: Provides Ethereum JSON-RPC endpoints.
Key Benefits¶
- Ethereum tooling compatibility: Full compatibility with MetaMask, Hardhat, Remix, Foundry, and other Ethereum development tools.
- Minimal-friction migration: Deployment of existing Ethereum dApps with minimal or no modifications.
- Native Ethereum formats: Support for Ethereum transaction formats, signatures, and gas mechanics.
- Block emulation: Ethereum-style block structure within Substrate's block production.
Implementation Examples¶
Production implementations demonstrate Frontier's capabilities:
- Moonbeam: See their implementation of
pallet-evmandpallet-ethereum.
pallet-contracts (Legacy)¶
pallet-contracts is the original Wasm-based smart contract pallet for Polkadot SDK chains. While still functional, it's considered legacy as development efforts have shifted to pallet-revive.
Implementation Example¶
For reference, Astar's implementation of pallet-contracts demonstrates production usage.
Where to Go Next¶
-
Guide Add a Pallet to the Runtime
Learn the step-by-step process for integrating Polkadot SDK pallets into your blockchain's runtime.
| Created: January 14, 2026