You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .ai/categories/parachains.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1256,9 +1256,9 @@ Any language that can compile to PolkaVM bytecode and utilize `pallet-revive`'s
1256
1256
1257
1257
### Key Benefits
1258
1258
1259
-
- **Unified Platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet.
1259
+
- **Unified platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet.
1260
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.
1261
+
- **Ethereum compatibility**: Supports full integration with Ethereum tooling via RPC adapter.
1262
1262
1263
1263
### Implementation Examples
1264
1264
@@ -1276,7 +1276,7 @@ Frontier offers flexible integration depending on your compatibility needs:
1276
1276
1277
1277
For basic EVM support using Polkadot SDK native APIs:
1278
1278
1279
-
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment
1279
+
- **[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment.
1280
1280
1281
1281
This configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction.
1282
1282
@@ -1290,20 +1290,20 @@ For complete Ethereum ecosystem integration with Ethereum RPC support:
1290
1290
1291
1291
### Key Benefits
1292
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
1293
+
- **Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Foundry, 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
1297
1298
1298
### Implementation Examples
1299
1299
1300
1300
Production implementations demonstrate Frontier's capabilities:
1301
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}
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
1303
1304
1304
## pallet-contracts (Legacy)
1305
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.
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`.
Copy file name to clipboardExpand all lines: .ai/categories/smart-contracts.md
+154Lines changed: 154 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10585,6 +10585,160 @@ Your local development environment is now active and accessible at `http://local
10585
10585
You can connect wallets, deploy contracts using Remix or Hardhat, and interact with your smart contracts as you would on any Ethereum-compatible network.
- Summary: Learn how to migrate your existing Ethereum contracts to the Polkadot Hub using REVM and PolkaVM by following these considerations.
10595
+
10596
+
# Migration FAQs and Considerations
10597
+
10598
+
## Introduction
10599
+
10600
+
This guide helps Ethereum developers migrate their smart contracts to Polkadot Hub. Most contracts work without modifications on the REVM backend, while the PolkaVM backend offers enhanced performance with minimal adaptation for standard patterns.
10601
+
10602
+
## Migration Considerations
10603
+
10604
+
Take into account the following considerations before migrating your contracts:
10605
+
10606
+
- Standard ERC-20, ERC-721, ERC-1155 tokens work without changes.
10607
+
- DeFi protocols, DEXs, and AMMs migrate seamlessly.
10608
+
- DAOs and governance contracts are fully compatible.
10609
+
- Most Solidity contracts deploy identically to Ethereum.
10610
+
10611
+
## Migration Checklist
10612
+
10613
+
Before migrating your contracts, review this checklist:
10614
+
10615
+
- Factory contracts using PVM bytecode need pre-uploaded dependencies.
10616
+
- Contracts using `EXTCODECOPY` for runtime manipulation require review (for projects that will use PVM bytecode, not EVM bytecode).
10617
+
- Replace `transfer()` and `send()` with proper reentrancy guards (for projects that will use PVM bytecode, not EVM bytecode).
10618
+
10619
+
## Migration FAQs
10620
+
10621
+
### Which backend should I choose?
10622
+
10623
+
- Choose REVM if you want:
10624
+
10625
+
- Zero-modification deployment of existing Ethereum contracts.
10626
+
- Exact EVM behavior for audited code.
10627
+
- Compatibility with tools that inspect EVM bytecode.
10628
+
- Rapid deployment without optimization.
10629
+
10630
+
- Choose PolkaVM if you want:
10631
+
10632
+
- Better performance for computation-heavy applications.
10633
+
- Lower execution costs for intensive operations.
10634
+
- Access to next-generation smart contract features.
10635
+
10636
+
If you are unsure which to choose, start with REVM for immediate compatibility, then consider PolkaVM for performance optimization once deployed.
10637
+
10638
+
### Do I need to rewrite my Solidity code?
10639
+
10640
+
No, for most contracts. Standard Solidity patterns work on both backends.
10641
+
10642
+
### What about factory contracts?
10643
+
10644
+
- **REVM**: Factory contracts work identically to Ethereum with no changes needed.
10645
+
10646
+
The original factory pattern is:
10647
+
10648
+
```solidity
10649
+
contract TokenFactory {
10650
+
function createToken(string memory name) public returns (address) {
function createToken(string memory name) public returns (address) {
10672
+
// Instantiate from pre-uploaded code
10673
+
Token newToken = new Token{salt: keccak256(abi.encode(name))}(name);
10674
+
return address(newToken);
10675
+
}
10676
+
}
10677
+
```
10678
+
10679
+
The deployment steps for PolkaVM factories are:
10680
+
10681
+
1. Upload the contract code to the chain.
10682
+
2. Note the returned code hash.
10683
+
3. Deploy the Factory contract with the contract code hash.
10684
+
4. Factory can now instantiate contracts using the pre-uploaded code.
10685
+
10686
+
### How do gas costs compare?
10687
+
10688
+
For more information on gas costs, see the [Gas Model](/smart-contracts/for-eth-devs/gas-model/){target=\_blank} page.
10689
+
10690
+
### Which Solidity features are not supported?
10691
+
10692
+
For REVM, any Solidity feature will function smoothly without requiring changes or adaptations. For PVM, there are considerations, as was mentioned above.
10693
+
10694
+
For PolkaVM, there are some considerations:
10695
+
10696
+
- `EXTCODECOPY`: Only works in constructor code.
10697
+
- Runtime code modification: Use on-chain constructors instead.
10698
+
- **Gas stipends**: `address.send()` and `address.transfer()` don't provide reentrancy protection.
- **Development frameworks**: [Hardhat](/smart-contracts/cookbook/smart-contracts/deploy-basic/hardhat/){target=\_blank}, [Foundry](/smart-contracts/cookbook/smart-contracts/deploy-basic/foundry/){target=\_blank}, [Remix](/smart-contracts/cookbook/smart-contracts/deploy-basic/remix/){target=\_blank} (just consider that for PVM bytecode, you will use the Polkadot version of the tooling)
Chain interactions form the foundation of building applications on Polkadot. Whether you're querying on-chain data, executing transactions, enabling cross-chain communication, or managing accounts, understanding how to interact with Polkadot-based chains is essential for application developers.
13
+
14
+
This section provides comprehensive guidance on the various ways to interact with Polkadot chains, from basic queries to complex cross-chain operations. You'll learn how to:
15
+
16
+
- Query on-chain state and subscribe to blockchain events
17
+
- Send transactions and manage their lifecycle
18
+
- Enable interoperability between parachains through XCM
19
+
- Manage tokens and perform token operations
20
+
- Create and manage accounts programmatically
21
+
22
+
Whether you're building a frontend application, a backend service, or integrating with the Polkadot ecosystem, these guides will equip you with the knowledge and tools to effectively interact with chains across the network.
23
+
24
+
## Core Interaction Patterns
25
+
26
+
### Query On-Chain Data
27
+
28
+
Accessing blockchain state is fundamental to building responsive applications. Polkadot provides multiple methods to query on-chain data, each suited for different use cases.
29
+
30
+
-**SDK Integration**: Use [Polkadot API (PAPI)](https://papi.how/){target=\_blank}, [Polkadot.js](https://polkadot.js.org/docs/){target=\_blank}, [Dedot](https://dedot.dev/){target=\_blank}, [PSI](https://github.com/paritytech/psi){target=\_blank}, or [Subxt](https://docs.rs/subxt/latest/subxt/){target=\_blank} to read blockchain state programmatically
31
+
32
+
-**REST API Access**: Query chain data through standardized REST endpoints for simpler integration
33
+
34
+
-**Runtime API Calls**: Execute runtime APIs directly for specialized queries and operations
35
+
36
+
Learn how to efficiently retrieve account balances, query storage, subscribe to events, and decode blockchain data in your applications.
37
+
38
+
### Send Transactions
39
+
40
+
Transactions are the primary mechanism for modifying blockchain state. Understanding transaction construction, signing, and submission is crucial for building interactive applications.
41
+
42
+
-**Transaction Construction**: Build transactions using various SDKs with proper encoding and formatting
43
+
-**Fee Estimation**: Calculate transaction fees to ensure sufficient balance and optimize costs
44
+
-**Multi-Token Fees**: Learn how to pay transaction fees with different tokens on supported chains
45
+
46
+
### Interoperability
47
+
48
+
Polkadot's true power lies in its native cross-chain capabilities. Through Cross-Consensus Messaging (XCM), chains can securely communicate and transfer assets across the ecosystem.
49
+
50
+
-**XCM Fundamentals**: Understand how to construct and send XCM messages between parachains using [ParaSpell XCM SDK](https://paraspell.github.io/docs/){target=\_blank} and [Polkadot API (PAPI)](https://papi.how/){target=\_blank}
51
+
-**Asset Transfers**: Transfer tokens and other assets between different chains seamlessly
52
+
-**Cross-Chain Communication**: Enable your applications to interact with multiple parachains
53
+
-**Bridge Integration**: Connect to blockchains outside the Polkadot ecosystem using Snowbridge and other bridge solutions
54
+
55
+
Master the tools for estimating transfer costs, debugging XCM messages, and implementing robust cross-chain workflows.
56
+
57
+
### Token Operations
58
+
59
+
Polkadot Hub provides a unified platform for managing assets across the ecosystem. Understanding token operations is essential for DeFi applications and multi-chain asset management.
60
+
61
+
-**Asset Registration**: Learn how local and foreign assets are registered on the network
62
+
-**Asset Hub Integration**: Interact with Polkadot's central asset management hub using [Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank}
63
+
-**Cross-Chain Assets**: Handle assets that exist across multiple parachains
64
+
65
+
### Accounts
66
+
67
+
Account management forms the basis of user identity and authentication in blockchain applications. Learn how to create, manage, and query accounts programmatically.
68
+
69
+
-**Account Creation**: Generate accounts using various SDKs in Rust, Python, and JavaScript
70
+
-**Account Queries**: Retrieve account information including balances, nonces, and metadata
71
+
72
+
## Development Tools and SDKs
73
+
74
+
The Polkadot ecosystem offers a rich set of tools and libraries to facilitate chain interactions:
75
+
76
+
-**[Polkadot API (PAPI)](https://papi.how/){target=\_blank}**: Modern, type-safe TypeScript library with full metadata support
77
+
-**[Polkadot.js](https://polkadot.js.org/docs/){target=\_blank}**: Comprehensive JavaScript library with extensive ecosystem support
78
+
-**[Dedot](https://dedot.dev/){target=\_blank}**: Lightweight TypeScript library optimized for performance
79
+
-**[PSI](https://github.com/paritytech/psi){target=\_blank}**: Polkadot Substrate Interface for streamlined development
80
+
-**[Subxt](https://docs.rs/subxt/latest/subxt/){target=\_blank}**: Rust library for building robust substrate-based applications
81
+
-**[Polkadot.js Apps](https://polkadot.js.org/apps/){target=\_blank}**: Web-based interface for exploring and interacting with chains
82
+
83
+
Each tool has its strengths, and choosing the right one depends on your project requirements, programming language preference, and specific use cases.
84
+
85
+
## Next Steps
86
+
87
+
Explore the sections below to dive deeper into specific chain interaction patterns:
88
+
89
+
-**[Query On-Chain Data](/chain-interactions/query-data/query-sdks/)**: Learn to read blockchain state efficiently
90
+
-**[Send Transactions](/chain-interactions/send-transactions/with-sdks/)**: Master transaction construction and submission
91
+
-**[Interoperability](/chain-interactions/send-transactions/interoperability/transfer-assets-parachains/)**: Enable cross-chain communication with XCM
92
+
-**[Token Operations](/chain-interactions/token-operations/register-local-asset/)**: Manage assets across the Polkadot ecosystem
93
+
-**[Accounts](/chain-interactions/accounts/create-account/)**: Create and query accounts programmatically
94
+
95
+
Each section provides practical examples, code snippets, and comprehensive guides to help you build production-ready applications on Polkadot.
0 commit comments