Skip to content

Commit 4a76f17

Browse files
committed
Refactor contract-deployment.md to focus on theoretical guidance
Replace practical tool commands with conceptual content covering: - Deployment model (CREATE/CREATE2 opcodes) - Transaction processing architecture - Gas estimation behavior and multi-dimensional resource model - Storage model and deposits - Address derivation algorithms - Finality considerations This aligns the page with the for-eth-devs section's purpose of providing theoretical guidance rather than practical how-to instructions.
1 parent 9df0eb5 commit 4a76f17

File tree

6 files changed

+138
-84
lines changed

6 files changed

+138
-84
lines changed
Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Contract Deployment
3-
description: Learn how to deploy Solidity smart contracts to Polkadot Hub using familiar Ethereum tooling and workflows.
3+
description: Understand how smart contract deployment works on Polkadot Hub compared to Ethereum, including transaction processing, gas estimation, and storage considerations.
44
categories: Smart Contracts, Basics
55
url: https://docs.polkadot.com/smart-contracts/for-eth-devs/contract-deployment/
66
---
@@ -9,61 +9,88 @@ url: https://docs.polkadot.com/smart-contracts/for-eth-devs/contract-deployment/
99

1010
## Introduction
1111

12-
Deploying smart contracts to Polkadot Hub works exactly like deploying to Ethereum. Use your existing Solidity contracts, familiar tools like Hardhat, Foundry, or Remix, and deploy without any modifications.
12+
Smart contract deployment on Polkadot Hub follows the same conceptual model as Ethereum. This page explains the underlying mechanisms and key behavioral differences that Ethereum developers should understand when deploying contracts to Polkadot Hub.
1313

14-
## Deployment Process
14+
## Deployment Model
1515

16-
Polkadot Hub uses the REVM backend, which provides full Ethereum compatibility. This means:
16+
Polkadot Hub uses the REVM backend, which implements the Ethereum Virtual Machine specification. This means deployment transactions are processed identically to Ethereum:
1717

18-
- **Single-step deployment**: Contracts deploy in a single transaction, just like Ethereum.
19-
- **Factory patterns work**: Create new contracts at runtime using standard factory patterns.
20-
- **Full Solidity support**: All Solidity features including inline assembly are supported.
21-
- **Familiar tools**: Hardhat, Foundry, Remix, and other Ethereum tools work out of the box.
18+
- **CREATE opcode**: Deploys contracts to deterministic addresses based on sender and nonce
19+
- **CREATE2 opcode**: Enables counterfactual deployment with salt-based address derivation
20+
- **Constructor execution**: Runs initialization code and returns runtime bytecode
21+
- **Factory patterns**: Contracts can deploy other contracts at runtime without restrictions
2222

23-
## Using Your Existing Workflow
23+
The deployment transaction contains the contract's initialization bytecode in the `data` field, and the EVM executes this code to produce the runtime bytecode stored on-chain.
2424

25-
### With Hardhat
25+
## Transaction Processing
2626

27-
```bash
28-
npx hardhat ignition deploy ./ignition/modules/MyContract.ts --network polkadotHub
29-
```
27+
When you submit a deployment transaction, it flows through the following layers:
3028

31-
### With Foundry
29+
1. **JSON-RPC Proxy** - Receives the standard Ethereum transaction format
30+
2. **Transaction Repackaging** - Wraps the Ethereum transaction in a Substrate extrinsic
31+
3. **pallet_revive** - Decodes and executes the EVM transaction
32+
4. **REVM Execution** - Processes the deployment using standard EVM semantics
33+
5. **State Commitment** - Stores the contract code and initializes storage
3234

33-
```bash
34-
forge create --rpc-url $POLKADOT_HUB_RPC --private-key $PRIVATE_KEY src/MyContract.sol:MyContract
35-
```
35+
This architecture means your deployment transactions look and behave exactly like Ethereum transactions from the client perspective, while benefiting from Polkadot's consensus and finality guarantees.
3636

37-
### With Remix
37+
## Gas Estimation Behavior
3838

39-
1. Connect MetaMask to Polkadot Hub
40-
2. Select "Injected Provider - MetaMask" in Remix
41-
3. Deploy as you would to any EVM chain
39+
Ethereum developers may notice that gas estimates on Polkadot Hub are higher than actual consumption. This is expected behavior stemming from architectural differences:
4240

43-
## Gas Estimation
41+
### Why Estimates Differ
4442

45-
You might notice that gas estimates are higher than actual consumption (often around 30% of the estimate is used). This is normal behavior because:
43+
Polkadot's runtime uses a multi-dimensional resource model:
4644

47-
- Pre-dispatch estimation cannot distinguish between computation weight and storage deposits
48-
- Contract deployments consume significant storage deposits for code storage
49-
- The system uses conservative overestimation to ensure transactions succeed
45+
- **Computation weight** - Processing time consumed by the transaction
46+
- **Proof size** - Data required for light client verification
47+
- **Storage deposits** - Refundable deposits for on-chain storage
5048

51-
## Network Configuration
49+
When you call `eth_estimateGas`, the system must return a single gas value that covers all three dimensions. Since pre-dispatch estimation cannot perfectly predict the breakdown between computation and storage, the system uses conservative overestimation.
5250

53-
Add Polkadot Hub to your development environment:
51+
### Practical Impact
5452

55-
| Parameter | Value |
56-
|-----------|-------|
57-
| Network Name | Polkadot Hub TestNet |
58-
| RPC URL | `https://testnet-passet-hub-eth-rpc.polkadot.io` |
59-
| Chain ID | `420420421` |
60-
| Currency Symbol | PAS |
61-
| Block Explorer | [BlockScout](https://blockscout-passet-hub.parity-testnet.parity.io/){target=\_blank} |
53+
- Estimates may show 3x the actual gas consumed
54+
- Transactions still succeed because the estimate provides sufficient headroom
55+
- Actual costs are based on real consumption, not the estimate
56+
- Unused gas is refunded as on Ethereum
6257

63-
## Next Steps
58+
This behavior does not affect transaction success or final costs—it only means the estimated values appear higher than what you might expect from Ethereum mainnet.
6459

65-
Once deployed, your contracts can:
60+
## Storage Model
6661

67-
- Interact with other contracts on Polkadot Hub
68-
- Access Polkadot-native functionality via [precompiles](/smart-contracts/precompiles/)
69-
- Communicate cross-chain using [XCM](/smart-contracts/precompiles/xcm/)
62+
Contract deployment consumes storage for:
63+
64+
- **Code storage** - The runtime bytecode is stored on-chain
65+
- **Account creation** - A new account entry is created for the contract
66+
- **Initial state** - Any storage slots set during construction
67+
68+
Polkadot Hub uses a storage deposit system where deployers pay a refundable deposit proportional to the storage consumed. This deposit is returned when the contract is destroyed and storage is freed.
69+
70+
## Address Derivation
71+
72+
Contract addresses are derived using the same algorithms as Ethereum:
73+
74+
| Method | Address Calculation |
75+
|--------|-------------------|
76+
| CREATE | `keccak256(rlp([sender, nonce]))[12:]` |
77+
| CREATE2 | `keccak256(0xff ++ sender ++ salt ++ keccak256(init_code))[12:]` |
78+
79+
This means you can predict deployment addresses using the same tools and techniques as on Ethereum.
80+
81+
## Finality Considerations
82+
83+
Unlike Ethereum's probabilistic finality, Polkadot provides deterministic finality through its GRANDPA consensus mechanism. Once a block containing your deployment is finalized:
84+
85+
- The contract deployment is irreversible
86+
- No chain reorganization can remove the contract
87+
- Finality typically occurs within seconds, not minutes
88+
89+
This faster finality means you can begin interacting with deployed contracts more quickly and with stronger guarantees than on Ethereum.
90+
91+
## Where to Go Next
92+
93+
For step-by-step deployment tutorials using specific tools, see:
94+
95+
- [Deploy with Remix](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/) - Browser-based deployment walkthrough
96+
- [Hardhat Setup](/smart-contracts/dev-environments/hardhat/) - Local development environment configuration

.ai/pages/smart-contracts-for-eth-devs-ethereum-compatibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Most developers should start with REVM for its simplicity and full Ethereum comp
7575

7676
---
7777

78-
Learn how to deploy your Solidity contracts to Polkadot Hub.
78+
Understand deployment mechanics, gas estimation behavior, and storage considerations.
7979

8080
[:octicons-arrow-right-24: Reference](/smart-contracts/for-eth-devs/contract-deployment/)
8181

.ai/pages/smart-contracts-get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Bridge your Ethereum knowledge with Polkadot Hub specifics: account mapping, fee
3939
| [Accounts](/smart-contracts/for-eth-devs/accounts/) | How 20‑byte Ethereum addresses map to 32‑byte Polkadot accounts |
4040
| [Blocks, Transactions, and Fees](/smart-contracts/for-eth-devs/blocks-transactions-fees/) | Transaction types, fees, and multi‑dimensional metering |
4141
| [Gas Model](/smart-contracts/for-eth-devs/gas-model/) | Gas vs. weight, proof size, and storage deposits |
42-
| [Contract Deployment](/smart-contracts/for-eth-devs/contract-deployment/) | Deployment patterns and best practices on Polkadot Hub |
42+
| [Contract Deployment](/smart-contracts/for-eth-devs/contract-deployment/) | Deployment mechanics, gas estimation, and storage model |
4343
| [JSON‑RPC APIs](/smart-contracts/for-eth-devs/json-rpc-apis/) | Supported Ethereum JSON‑RPC methods and examples |
4444
| [Dual VM Stack](/smart-contracts/for-eth-devs/dual-vm-stack/) | Overview of EVM and native execution on the Hub |
4545

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,95 @@
11
---
22
title: Contract Deployment
3-
description: Learn how to deploy Solidity smart contracts to Polkadot Hub using familiar Ethereum tooling and workflows.
3+
description: Understand how smart contract deployment works on Polkadot Hub compared to Ethereum, including transaction processing, gas estimation, and storage considerations.
44
categories: Smart Contracts, Basics
55
---
66

77
# Contract Deployment
88

99
## Introduction
1010

11-
Deploying smart contracts to Polkadot Hub works exactly like deploying to Ethereum. Use your existing Solidity contracts, familiar tools like Hardhat, Foundry, or Remix, and deploy without any modifications.
11+
Smart contract deployment on Polkadot Hub follows the same conceptual model as Ethereum. This page explains the underlying mechanisms and key behavioral differences that Ethereum developers should understand when deploying contracts to Polkadot Hub.
1212

13-
## Deployment Process
13+
## Deployment Model
1414

15-
Polkadot Hub uses the REVM backend, which provides full Ethereum compatibility. This means:
15+
Polkadot Hub uses the REVM backend, which implements the Ethereum Virtual Machine specification. This means deployment transactions are processed identically to Ethereum:
1616

17-
- **Single-step deployment**: Contracts deploy in a single transaction, just like Ethereum.
18-
- **Factory patterns work**: Create new contracts at runtime using standard factory patterns.
19-
- **Full Solidity support**: All Solidity features including inline assembly are supported.
20-
- **Familiar tools**: Hardhat, Foundry, Remix, and other Ethereum tools work out of the box.
17+
- **CREATE opcode**: Deploys contracts to deterministic addresses based on sender and nonce
18+
- **CREATE2 opcode**: Enables counterfactual deployment with salt-based address derivation
19+
- **Constructor execution**: Runs initialization code and returns runtime bytecode
20+
- **Factory patterns**: Contracts can deploy other contracts at runtime without restrictions
2121

22-
## Using Your Existing Workflow
22+
The deployment transaction contains the contract's initialization bytecode in the `data` field, and the EVM executes this code to produce the runtime bytecode stored on-chain.
2323

24-
### With Hardhat
24+
## Transaction Processing
2525

26-
```bash
27-
npx hardhat ignition deploy ./ignition/modules/MyContract.ts --network polkadotHub
28-
```
26+
When you submit a deployment transaction, it flows through the following layers:
2927

30-
### With Foundry
28+
1. **JSON-RPC Proxy** - Receives the standard Ethereum transaction format
29+
2. **Transaction Repackaging** - Wraps the Ethereum transaction in a Substrate extrinsic
30+
3. **pallet_revive** - Decodes and executes the EVM transaction
31+
4. **REVM Execution** - Processes the deployment using standard EVM semantics
32+
5. **State Commitment** - Stores the contract code and initializes storage
3133

32-
```bash
33-
forge create --rpc-url $POLKADOT_HUB_RPC --private-key $PRIVATE_KEY src/MyContract.sol:MyContract
34-
```
34+
This architecture means your deployment transactions look and behave exactly like Ethereum transactions from the client perspective, while benefiting from Polkadot's consensus and finality guarantees.
3535

36-
### With Remix
36+
## Gas Estimation Behavior
3737

38-
1. Connect MetaMask to Polkadot Hub
39-
2. Select "Injected Provider - MetaMask" in Remix
40-
3. Deploy as you would to any EVM chain
38+
Ethereum developers may notice that gas estimates on Polkadot Hub are higher than actual consumption. This is expected behavior stemming from architectural differences:
4139

42-
## Gas Estimation
40+
### Why Estimates Differ
4341

44-
You might notice that gas estimates are higher than actual consumption (often around 30% of the estimate is used). This is normal behavior because:
42+
Polkadot's runtime uses a multi-dimensional resource model:
4543

46-
- Pre-dispatch estimation cannot distinguish between computation weight and storage deposits
47-
- Contract deployments consume significant storage deposits for code storage
48-
- The system uses conservative overestimation to ensure transactions succeed
44+
- **Computation weight** - Processing time consumed by the transaction
45+
- **Proof size** - Data required for light client verification
46+
- **Storage deposits** - Refundable deposits for on-chain storage
4947

50-
## Network Configuration
48+
When you call `eth_estimateGas`, the system must return a single gas value that covers all three dimensions. Since pre-dispatch estimation cannot perfectly predict the breakdown between computation and storage, the system uses conservative overestimation.
5149

52-
Add Polkadot Hub to your development environment:
50+
### Practical Impact
5351

54-
| Parameter | Value |
55-
|-----------|-------|
56-
| Network Name | Polkadot Hub TestNet |
57-
| RPC URL | `https://testnet-passet-hub-eth-rpc.polkadot.io` |
58-
| Chain ID | `420420421` |
59-
| Currency Symbol | PAS |
60-
| Block Explorer | [BlockScout](https://blockscout-passet-hub.parity-testnet.parity.io/){target=\_blank} |
52+
- Estimates may show 3x the actual gas consumed
53+
- Transactions still succeed because the estimate provides sufficient headroom
54+
- Actual costs are based on real consumption, not the estimate
55+
- Unused gas is refunded as on Ethereum
6156

62-
## Next Steps
57+
This behavior does not affect transaction success or final costs—it only means the estimated values appear higher than what you might expect from Ethereum mainnet.
6358

64-
Once deployed, your contracts can:
59+
## Storage Model
6560

66-
- Interact with other contracts on Polkadot Hub
67-
- Access Polkadot-native functionality via [precompiles](/smart-contracts/precompiles/)
68-
- Communicate cross-chain using [XCM](/smart-contracts/precompiles/xcm/)
61+
Contract deployment consumes storage for:
62+
63+
- **Code storage** - The runtime bytecode is stored on-chain
64+
- **Account creation** - A new account entry is created for the contract
65+
- **Initial state** - Any storage slots set during construction
66+
67+
Polkadot Hub uses a storage deposit system where deployers pay a refundable deposit proportional to the storage consumed. This deposit is returned when the contract is destroyed and storage is freed.
68+
69+
## Address Derivation
70+
71+
Contract addresses are derived using the same algorithms as Ethereum:
72+
73+
| Method | Address Calculation |
74+
|--------|-------------------|
75+
| CREATE | `keccak256(rlp([sender, nonce]))[12:]` |
76+
| CREATE2 | `keccak256(0xff ++ sender ++ salt ++ keccak256(init_code))[12:]` |
77+
78+
This means you can predict deployment addresses using the same tools and techniques as on Ethereum.
79+
80+
## Finality Considerations
81+
82+
Unlike Ethereum's probabilistic finality, Polkadot provides deterministic finality through its GRANDPA consensus mechanism. Once a block containing your deployment is finalized:
83+
84+
- The contract deployment is irreversible
85+
- No chain reorganization can remove the contract
86+
- Finality typically occurs within seconds, not minutes
87+
88+
This faster finality means you can begin interacting with deployed contracts more quickly and with stronger guarantees than on Ethereum.
89+
90+
## Where to Go Next
91+
92+
For step-by-step deployment tutorials using specific tools, see:
93+
94+
- [Deploy with Remix](/smart-contracts/cookbook/smart-contracts/deploy-basic/basic-remix/) - Browser-based deployment walkthrough
95+
- [Hardhat Setup](/smart-contracts/dev-environments/hardhat/) - Local development environment configuration

smart-contracts/for-eth-devs/ethereum-compatibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Most developers should start with REVM for its simplicity and full Ethereum comp
7474

7575
---
7676

77-
Learn how to deploy your Solidity contracts to Polkadot Hub.
77+
Understand deployment mechanics, gas estimation behavior, and storage considerations.
7878

7979
[:octicons-arrow-right-24: Reference](/smart-contracts/for-eth-devs/contract-deployment/)
8080

smart-contracts/get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Bridge your Ethereum knowledge with Polkadot Hub specifics: account mapping, fee
3838
| [Accounts](/smart-contracts/for-eth-devs/accounts/) | How 20‑byte Ethereum addresses map to 32‑byte Polkadot accounts |
3939
| [Blocks, Transactions, and Fees](/smart-contracts/for-eth-devs/blocks-transactions-fees/) | Transaction types, fees, and multi‑dimensional metering |
4040
| [Gas Model](/smart-contracts/for-eth-devs/gas-model/) | Gas vs. weight, proof size, and storage deposits |
41-
| [Contract Deployment](/smart-contracts/for-eth-devs/contract-deployment/) | Deployment patterns and best practices on Polkadot Hub |
41+
| [Contract Deployment](/smart-contracts/for-eth-devs/contract-deployment/) | Deployment mechanics, gas estimation, and storage model |
4242
| [JSON‑RPC APIs](/smart-contracts/for-eth-devs/json-rpc-apis/) | Supported Ethereum JSON‑RPC methods and examples |
4343
| [Dual VM Stack](/smart-contracts/for-eth-devs/dual-vm-stack/) | Overview of EVM and native execution on the Hub |
4444

0 commit comments

Comments
 (0)