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/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)
Copy file name to clipboardExpand all lines: .ai/pages/parachains-customize-runtime-add-smart-contract-functionality.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
@@ -50,9 +50,9 @@ Any language that can compile to PolkaVM bytecode and utilize `pallet-revive`'s
50
50
51
51
### Key Benefits
52
52
53
-
-**Unified Platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet.
53
+
-**Unified platform**: Deploys both PolkaVM-optimized and EVM-compatible contracts using a single pallet.
54
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.
55
+
-**Ethereum compatibility**: Supports full integration with Ethereum tooling via RPC adapter.
56
56
57
57
### Implementation Examples
58
58
@@ -70,7 +70,7 @@ Frontier offers flexible integration depending on your compatibility needs:
70
70
71
71
For basic EVM support using Polkadot SDK native APIs:
72
72
73
-
-**[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment
73
+
-**[`pallet-evm`](https://github.com/polkadot-evm/frontier/tree/master/frame/evm){target=\_blank}**: Provides the core EVM execution environment.
74
74
75
75
This configuration allows EVM contract execution but requires using Polkadot SDK-specific APIs for interaction.
76
76
@@ -84,20 +84,20 @@ For complete Ethereum ecosystem integration with Ethereum RPC support:
84
84
85
85
### Key Benefits
86
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
87
+
-**Ethereum tooling compatibility**: Full compatibility with MetaMask, Hardhat, Remix, Foundry, 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
91
92
92
### Implementation Examples
93
93
94
94
Production implementations demonstrate Frontier's capabilities:
95
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}
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
97
98
98
## pallet-contracts (Legacy)
99
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.
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`.
0 commit comments