Skip to content

Commit d8fb1a4

Browse files
committed
Merge branch 'staging/product-ia' into bruno/pallet-unit-testing
2 parents 14e698b + ff7c97f commit d8fb1a4

File tree

488 files changed

+37587
-32594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+37587
-32594
lines changed

.ai/categories/basics.md

Lines changed: 1049 additions & 207 deletions
Large diffs are not rendered by default.

.ai/categories/dapps.md

Lines changed: 1053 additions & 211 deletions
Large diffs are not rendered by default.

.ai/categories/infrastructure.md

Lines changed: 1049 additions & 207 deletions
Large diffs are not rendered by default.

.ai/categories/networks.md

Lines changed: 1049 additions & 207 deletions
Large diffs are not rendered by default.

.ai/categories/parachains.md

Lines changed: 5838 additions & 4777 deletions
Large diffs are not rendered by default.

.ai/categories/polkadot-protocol.md

Lines changed: 1049 additions & 207 deletions
Large diffs are not rendered by default.

.ai/categories/smart-contracts.md

Lines changed: 5945 additions & 2661 deletions
Large diffs are not rendered by default.

.ai/categories/tooling.md

Lines changed: 4942 additions & 3169 deletions
Large diffs are not rendered by default.
Lines changed: 80 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Add Smart Contract Functionality
3-
description: Add smart contract capabilities to your Polkadot SDK-based blockchain. Explore EVM and Wasm integration for enhanced chain functionality.
3+
description: Add smart contract capabilities to your Polkadot SDK-based blockchain. Explore PVM, EVM, and Wasm integration for enhanced chain functionality.
44
categories: Parachains
55
url: https://docs.polkadot.com/parachains/customize-runtime/add-smart-contract-functionality/
66
---
@@ -9,59 +9,110 @@ url: https://docs.polkadot.com/parachains/customize-runtime/add-smart-contract-f
99

1010
## Introduction
1111

12-
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.
12+
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.
1313

14-
Polkadot SDK-based blockchains support two distinct smart contract execution environments: [EVM (Ethereum Virtual Machine)](#evm-smart-contracts) and [Wasm (WebAssembly)](#wasm-smart-contracts). Each environment allows developers to deploy and execute different types of smart contracts, providing flexibility in choosing the most suitable solution for their needs.
14+
This guide covers three approaches to adding smart contracts to your blockchain:
1515

16-
## EVM Smart Contracts
16+
- **[`pallet-revive`](#pallet-revive)**: Modern unified solution supporting both PolkaVM and EVM bytecode
17+
- **[Frontier](#frontier)**: Ethereum compatibility layer for Polkadot SDK-based chains
18+
- **[`pallet-contracts`](#pallet-contracts-legacy)**: Wasm smart contract support
1719

18-
To enable Ethereum-compatible smart contracts in your blockchain, you'll need to integrate [Frontier](https://github.com/polkadot-evm/frontier){target=\_blank}, the Ethereum compatibility layer for Polkadot SDK-based chains. This requires adding two essential pallets to your runtime:
20+
## pallet-revive
1921

20-
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the EVM execution environment.
21-
- **[`pallet-ethereum`](https://github.com/polkadot-evm/frontier/tree/master/frame/ethereum){target=\_blank}**: Handles Ethereum-formatted transactions and RPC capabilities.
22+
[`pallet-revive`](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/revive){target=\_blank} is the modern smart contract solution for Polkadot SDK-based chains. It provides a unified execution environment that supports both PolkaVM and EVM bytecode through dual execution backends.
2223

23-
For step-by-step guidance on adding these pallets to your runtime, refer to [Add a Pallet to the Runtime](/parachains/customize-runtime/add-existing-pallets/){target=\_blank}.
24+
### Core Components
2425

25-
For a real-world example of how these pallets are implemented in production, you can check Moonbeam's implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\_blank}.
26+
**Essential Pallet:**
27+
**[`pallet-revive`](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/revive){target=\_blank}** provides the core smart contract execution environment with [PolkaVM](https://github.com/polkadot-developers/polkadot-docs/blob/71e1b51bb42ef55e20c2f3b953db86e8c26cd591/smart-contracts/for-eth-devs/dual-vm-stack.md#upgrade-to-polkavm){target=\_blank} and [REVM](https://github.com/polkadot-developers/polkadot-docs/blob/71e1b51bb42ef55e20c2f3b953db86e8c26cd591/smart-contracts/for-eth-devs/dual-vm-stack.md#migrate-from-evm){target=\_blank} backends.
2628

27-
## Wasm Smart Contracts
29+
**RPC Adapter:**
30+
**[`pallet-revive-eth-rpc`](https://crates.io/crates/pallet-revive-eth-rpc){target=\_blank}** adds full Ethereum RPC compatibility for Ethereum tooling integration.
2831

29-
To support Wasm-based smart contracts, you'll need to integrate:
32+
### Supported Languages and Compilers
3033

31-
- **[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\_blank}**: Provides the Wasm smart contract execution environment.
34+
`pallet-revive` accepts smart contracts from multiple languages and compilation paths:
3235

33-
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](/parachains/customize-runtime/add-existing-pallets/){target=\_blank}.
36+
| Language | Compiler | Output Bytecode | Execution Backend |
37+
|----------|----------|-----------------|-------------------|
38+
| Solidity | `resolc` | PolkaVM | PolkaVM |
39+
| Solidity | `solc` | EVM | REVM |
40+
| Rust (ink!) | `cargo-contract` | PolkaVM | PolkaVM |
3441

35-
For a real-world example of how this pallet is implemented in production, you can check Astar's implementation of [`pallet-contracts`](https://github.com/AstarNetwork/Astar/blob/b6f7a408d31377130c3713ed52941a06b5436402/runtime/astar/src/lib.rs#L693){target=\_blank}.
42+
Any language that can compile to PolkaVM bytecode and utilize `pallet-revive`'s host functions (via [`pallet-revive-uapi`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive_uapi/index.html){target=\_blank}) is supported.
3643

37-
## Where to Go Next
44+
### How It Works
3845

39-
Now that you understand how to enable smart contract functionality in your blockchain, you might want to:
46+
**Dual Execution Model:**
4047

41-
<div class="grid cards" markdown>
48+
1. **PolkaVM Backend**: Executes PolkaVM bytecode with native performance optimization.
49+
2. **REVM Backend**: Implements EVM bytecode for compatibility with existing Ethereum contracts, ensuring seamless migration.
4250

43-
- <span class="badge guide">Guide</span> __Get Started with Smart Contracts__
51+
### Key Benefits
4452

45-
---
53+
- **Unified Platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet.
54+
- **Performance**: PolkaVM execution provides improved performance compared to the traditional EVM, leveraging the [RISC-V](https://en.wikipedia.org/wiki/RISC-V){target=\_blank} architecture to map instructions to the CPU and requires little transpiling.
55+
- **Ethereum Compatibility**: Supports full integration with Ethereum tooling via RPC adapter.
4656

47-
Learn how developers can build smart contracts on Polkadot by leveraging the PolkaVM, Wasm/ink! or EVM contracts across many parachains.
57+
### Implementation Examples
4858

49-
[:octicons-arrow-right-24: Reference](/smart-contracts/get-started/)
59+
See a real-world implementation in the [Polkadot Hub TestNet](https://github.com/paseo-network/runtimes/blob/c965c42a4e0bc9d1e9cc0a340322bc3b8e347bcf/system-parachains/asset-hub-paseo/src/lib.rs#L1122-L1157){target=\_blank} in the Polkadot Fellows repository.
5060

51-
- <span class="badge guide">Guide</span> __Wasm (ink!) Contracts__
61+
## Frontier
5262

53-
---
63+
[Frontier](https://github.com/polkadot-evm/frontier){target=\_blank} 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.
64+
65+
### Integration Options
66+
67+
Frontier offers flexible integration depending on your compatibility needs:
68+
69+
### EVM Execution Only
70+
71+
For basic EVM support using Polkadot SDK native APIs:
72+
73+
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment
74+
75+
This configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction.
76+
77+
### Full Ethereum Compatibility
78+
79+
For complete Ethereum ecosystem integration with Ethereum RPC support:
80+
81+
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Integrates core EVM execution environment.
82+
- **[`pallet-ethereum`](https://github.com/polkadot-evm/frontier/tree/master/frame/ethereum){target=\_blank}**: Emulates Ethereum blocks and handles Ethereum-formatted transactions.
83+
- **[`fc-rpc`](https://github.com/polkadot-evm/frontier/tree/master/client/rpc){target=\_blank}**: Provides Ethereum JSON-RPC endpoints.
5484

55-
Learn to build Wasm smart contracts with ink!, a Rust-based eDSL. Explore installation, contract structure, and key features.
85+
### Key Benefits
86+
87+
- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Truffle, and other Ethereum development tools
88+
- **Minimal-friction migration**: Deployment of existing Ethereum dApps with minimal or no modifications
89+
- **Native Ethereum formats**: Support for Ethereum transaction formats, signatures, and gas mechanics
90+
- **Block emulation**: Ethereum-style block structure within Substrate's block production
91+
92+
### Implementation Examples
93+
94+
Production implementations demonstrate Frontier's capabilities:
95+
96+
- **Moonbeam**: See their implementation of [`pallet-evm`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L532){target=\_blank} and [`pallet-ethereum`](https://github.com/moonbeam-foundation/moonbeam/blob/9e2ddbc9ae8bf65f11701e7ccde50075e5fe2790/runtime/moonbeam/src/lib.rs#L698){target=\_blank}
97+
98+
## pallet-contracts (Legacy)
99+
100+
[`pallet-contracts`](https://docs.rs/pallet-contracts/latest/pallet_contracts/index.html#contracts-pallet){target=\_blank} 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.
101+
102+
### Implementation Example
103+
104+
For reference, Astar's implementation of [`pallet-contracts`](https://github.com/AstarNetwork/Astar/blob/b6f7a408d31377130c3713ed52941a06b5436402/runtime/astar/src/lib.rs#L693){target=\_blank} demonstrates production usage.
105+
106+
## Where to Go Next
107+
108+
<div class="grid cards" markdown>
56109

57-
[:octicons-arrow-right-24: Reference](/smart-contracts/overview/#wasm-ink)
58-
59-
- <span class="badge guide">Guide</span> __EVM Contracts__
110+
- <span class="badge guide">Guide</span> __Add a Pallet to the Runtime__
60111

61112
---
62113

63-
Learn how Polkadot parachains such as Moonbeam, Astar, Acala, and Manta leverage the Ethereum Virtual Machine (EVM) and integrate it into their parachains.
114+
Learn the step-by-step process for integrating Polkadot SDK pallets into your blockchain's runtime.
64115

65-
[:octicons-arrow-right-24: Reference](/smart-contracts/overview/#parachain-contracts)
116+
[:octicons-arrow-right-24: Get Started](/parachains/customize-runtime/add-existing-pallets/)
66117

67118
</div>

0 commit comments

Comments
 (0)