Skip to content

Add Smart Contract Functionality

Introduction

When building your custom blockchain with the Polkadot SDK, you have the flexibility to add smart contract capabilities through specialized pallets. These pallets allow blockchain users to deploy and execute smart contracts, enhancing your chain's functionality and programmability.

Polkadot SDK-based blockchains support two distinct smart contract execution environments: EVM (Ethereum Virtual Machine) and Wasm (WebAssembly). Each environment allows developers to deploy and execute different types of smart contracts, providing flexibility in choosing the most suitable solution for their needs.

EVM Smart Contracts

To enable Ethereum-compatible smart contracts in your blockchain, you'll need to integrate Frontier, the Ethereum compatibility layer for Polkadot SDK-based chains. This requires adding two essential pallets to your runtime:

  • pallet-evm - provides the EVM execution environment
  • pallet-ethereum - handles Ethereum-formatted transactions and RPC capabilities

For step-by-step guidance on adding these pallets to your runtime, refer to Add a Pallet to the Runtime.

For a real-world example of how these pallets are implemented in production, you can check Moonbeam's implementation of pallet-evm and pallet-ethereum.

Wasm Smart Contracts

To support Wasm-based smart contracts, you'll need to integrate:

This pallet enables the deployment and execution of Wasm-based smart contracts on your blockchain. For detailed instructions on adding this pallet to your runtime, see Add a Pallet to the Runtime.

For a real-world example of how this pallet is implemented in production, you can check Astar's implementation of pallet-contracts.

Where to Go Next

Now that you understand how to enable smart contract functionality in your blockchain, you might want to:

  • Guide Smart Contracts Overview


    Learn how developers can build smart contracts on Polkadot by leveraging either Wasm/ink! or EVM contracts across many parachains.

    Reference

  • Guide Wasm (ink!) Contracts


    Learn to build Wasm smart contracts with ink!, a Rust-based eDSL. Explore installation, contract structure, and key features.

    Reference

  • Guide EVM Contracts


    Learn how Polkadot parachains such as Moonbeam, Astar, Acala, and Manta leverage the Ethereum Virtual Machine (EVM) and integrate it into their parachains.

    Reference

Last update: December 12, 2024
| Created: November 20, 2024