Skip to content

Commit 6474683

Browse files
brunopgalvaoTeluceroeshaben
authored
Add smart contract functionality page (#1130)
* add smart contract supoort page * Applied feedback/formatted/fixed links * update llms/.ai * resolving conflicts * Apply suggestion from @eshaben Co-authored-by: Erin Shaben <[email protected]> * Apply suggestion from @eshaben Co-authored-by: Erin Shaben <[email protected]> * Apply suggestion from @eshaben Co-authored-by: Erin Shaben <[email protected]> * Apply suggestion from @eshaben Co-authored-by: Erin Shaben <[email protected]> * Apply suggestion from @eshaben Co-authored-by: Erin Shaben <[email protected]> * Apply suggestion from @eshaben Co-authored-by: Erin Shaben <[email protected]> --------- Co-authored-by: Taylor Lucero <[email protected]> Co-authored-by: Taylor Lucero <[email protected]> Co-authored-by: Erin Shaben <[email protected]>
1 parent b48ff7d commit 6474683

File tree

3 files changed

+240
-87
lines changed

3 files changed

+240
-87
lines changed

.ai/categories/parachains.md

Lines changed: 80 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,66 +1209,117 @@ Page Title: Add Smart Contract Functionality
12091209

12101210
- Source (raw): https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-add-smart-contract-functionality.md
12111211
- Canonical (HTML): https://docs.polkadot.com/parachains/customize-runtime/add-smart-contract-functionality/
1212-
- Summary: Add smart contract capabilities to your Polkadot SDK-based blockchain. Explore EVM and Wasm integration for enhanced chain functionality.
1212+
- Summary: Add smart contract capabilities to your Polkadot SDK-based blockchain. Explore PVM, EVM, and Wasm integration for enhanced chain functionality.
12131213

12141214
# Add Smart Contract Functionality
12151215

12161216
## Introduction
12171217

1218-
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.
1218+
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.
12191219

1220-
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.
1220+
This guide covers three approaches to adding smart contracts to your blockchain:
12211221

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

1224-
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:
1226+
## pallet-revive
12251227

1226-
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the EVM execution environment.
1227-
- **[`pallet-ethereum`](https://github.com/polkadot-evm/frontier/tree/master/frame/ethereum){target=\_blank}**: Handles Ethereum-formatted transactions and RPC capabilities.
1228+
[`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.
12281229

1229-
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}.
1230+
### Core Components
12301231

1231-
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}.
1232+
**Essential Pallet:**
1233+
**[`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.
12321234

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

1235-
To support Wasm-based smart contracts, you'll need to integrate:
1238+
### Supported Languages and Compilers
12361239

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

1239-
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}.
1242+
| Language | Compiler | Output Bytecode | Execution Backend |
1243+
|----------|----------|-----------------|-------------------|
1244+
| Solidity | `resolc` | PolkaVM | PolkaVM |
1245+
| Solidity | `solc` | EVM | REVM |
1246+
| Rust (ink!) | `cargo-contract` | PolkaVM | PolkaVM |
12401247

1241-
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}.
1248+
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.
12421249

1243-
## Where to Go Next
1250+
### How It Works
12441251

1245-
Now that you understand how to enable smart contract functionality in your blockchain, you might want to:
1252+
**Dual Execution Model:**
12461253

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

1249-
- <span class="badge guide">Guide</span> __Get Started with Smart Contracts__
1257+
### Key Benefits
12501258

1251-
---
1259+
- **Unified Platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet.
1260+
- **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.
1261+
- **Ethereum Compatibility**: Supports full integration with Ethereum tooling via RPC adapter.
12521262

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

1255-
[:octicons-arrow-right-24: Reference](/smart-contracts/get-started/)
1265+
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.
12561266

1257-
- <span class="badge guide">Guide</span> __Wasm (ink!) Contracts__
1267+
## Frontier
12581268

1259-
---
1269+
[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.
12601270

1261-
Learn to build Wasm smart contracts with ink!, a Rust-based eDSL. Explore installation, contract structure, and key features.
1271+
### Integration Options
12621272

1263-
[:octicons-arrow-right-24: Reference](/smart-contracts/overview/#wasm-ink)
1264-
1265-
- <span class="badge guide">Guide</span> __EVM Contracts__
1273+
Frontier offers flexible integration depending on your compatibility needs:
1274+
1275+
### EVM Execution Only
1276+
1277+
For basic EVM support using Polkadot SDK native APIs:
1278+
1279+
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment
1280+
1281+
This configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction.
1282+
1283+
### Full Ethereum Compatibility
1284+
1285+
For complete Ethereum ecosystem integration with Ethereum RPC support:
1286+
1287+
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Integrates core EVM execution environment.
1288+
- **[`pallet-ethereum`](https://github.com/polkadot-evm/frontier/tree/master/frame/ethereum){target=\_blank}**: Emulates Ethereum blocks and handles Ethereum-formatted transactions.
1289+
- **[`fc-rpc`](https://github.com/polkadot-evm/frontier/tree/master/client/rpc){target=\_blank}**: Provides Ethereum JSON-RPC endpoints.
1290+
1291+
### Key Benefits
1292+
1293+
- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Truffle, and other Ethereum development tools
1294+
- **Minimal-friction migration**: Deployment of existing Ethereum dApps with minimal or no modifications
1295+
- **Native Ethereum formats**: Support for Ethereum transaction formats, signatures, and gas mechanics
1296+
- **Block emulation**: Ethereum-style block structure within Substrate's block production
1297+
1298+
### Implementation Examples
1299+
1300+
Production implementations demonstrate Frontier's capabilities:
1301+
1302+
- **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}
1303+
1304+
## pallet-contracts (Legacy)
1305+
1306+
[`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.
1307+
1308+
### Implementation Example
1309+
1310+
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.
1311+
1312+
## Where to Go Next
1313+
1314+
<div class="grid cards" markdown>
1315+
1316+
- <span class="badge guide">Guide</span> __Add a Pallet to the Runtime__
12661317

12671318
---
12681319

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

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

12731324
</div>
12741325

0 commit comments

Comments
 (0)