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
PolkaVM smart contracts with Ethereum compatibility are in **early-stage development and may be unstable or incomplete**.
9642
9640
## Introduction
9643
9641
9644
9642
[viem](https://viem.sh/){target=\_blank} is a lightweight TypeScript library designed for interacting with Ethereum-compatible blockchains. This comprehensive guide will walk you through using viem to interact with and deploy smart contracts to Polkadot Hub.
@@ -9668,13 +9666,13 @@ viem-project/
9668
9666
│ └── interact.ts
9669
9667
├── contracts/
9670
9668
│ └── Storage.sol
9669
+
├── abis/
9670
+
│ └── Storage.json
9671
9671
└── artifacts/
9672
-
├── Storage.json
9673
-
└── Storage.polkavm
9672
+
└── Storage.bin
9674
9673
```
9675
9674
9676
-
## Set Up the Project
9677
-
9675
+
## Set Up the Proje
9678
9676
First, create a new folder and initialize your project:
9679
9677
9680
9678
```bash
@@ -9685,11 +9683,11 @@ npm init -y
9685
9683
9686
9684
## Install Dependencies
9687
9685
9688
-
Install viem along with other necessary dependencies, including [@parity/resolc](https://www.npmjs.com/package/@parity/resolc){target=\_blank}, which enables to compile smart contracts to [PolkaVM](/smart-contracts/for-eth-devs/#polkavm){target=\_blank} bytecode:
9686
+
Install viem along with other necessary dependencies, including [`solc`](https://www.npmjs.com/package/solc){target=\_blank}, which enables to compile smart contracts EVM bytecode:
http: ['https://testnet-passet-hub-eth-rpc.polkadot.io'], // TODO: change to paseo asset hub once ready
9810
9808
},
9811
9809
},
9812
9810
} as const;
@@ -9909,60 +9907,82 @@ contract Storage {
9909
9907
9910
9908
## Compile the Contract
9911
9909
9912
-
!!! note "Contracts Code Blob Size Disclaimer"
9913
-
The maximum contract code blob size on Polkadot Hub networks is _100 kilobytes_, significantly larger than Ethereum’s EVM limit of 24 kilobytes.
9914
-
9915
-
For detailed comparisons and migration guidelines, see the [EVM vs. PolkaVM](/polkadot-protocol/smart-contract-basics/evm-vs-polkavm/#current-memory-limits){target=\_blank} documentation page.
9916
-
9917
9910
Create a new file at `src/compile.ts` for handling contract compilation:
9918
9911
9919
9912
```typescript title="src/compile.ts"
9920
-
import { compile } from '@parity/resolc';
9921
-
import { readFileSync, writeFileSync } from 'fs';
9913
+
import solc from 'solc';
9914
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
@@ -9982,17 +10003,23 @@ To compile your contract:
9982
10003
npm run compile
9983
10004
```
9984
10005
9985
-
After executing this script, you will see the compilation results including the generated `Storage.json` (containing the contract's ABI) and `Storage.polkavm` (containing the compiled bytecode) files in the `artifacts` folder. These files contain all the necessary information for deploying and interacting with your smart contract on Polkadot Hub.
10006
+
After executing this script, you will see the compilation results including the generated `Storage.json` (containing the contract's ABI) and `Storage.vin` (containing the compiled bytecode) files in the `artifacts` folder. These files contain all the necessary information for deploying and interacting with your smart contract on Polkadot Hub.
9986
10007
9987
10008
## Deploy the Contract
9988
10009
9989
10010
Create a new file at `src/deploy.ts` for handling contract deployment:
0 commit comments