Skip to content

Commit 8894150

Browse files
authored
fix: snippets and step 3 (#771)
1 parent fcfe64f commit 8894150

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

develop/smart-contracts/libraries/ethers-js.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,23 @@ You can create a `deploy.js` script in the root of your project to achieve this.
161161
```js title="scripts/deploy.js"
162162
--8<-- 'code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js:7:15'
163163
```
164-
r2
164+
165165
3. Set up functions to read contract artifacts:
166166

167167
```js title="scripts/deploy.js"
168-
--8<-- 'code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js:17:45'
168+
--8<-- 'code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js:17:48'
169169
```
170170

171171
4. Create the main deployment function:
172172

173173
```js title="scripts/deploy.js"
174-
--8<-- 'code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js:47:82'
174+
--8<-- 'code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js:49:85'
175175
```
176176

177177
5. Configure and execute the deployment:
178178

179179
```js title="scripts/deploy.js"
180-
--8<-- 'code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js:84:92'
180+
--8<-- 'code/develop/smart-contracts/evm-toolkit/ethers-js/deploy.js:87:95'
181181
```
182182

183183
!!! note

llms.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9487,7 +9487,7 @@ const createProvider = (rpcUrl, chainId, chainName) => {
94879487
return provider;
94889488
};
94899489
```
9490-
r2
9490+
94919491
3. Set up functions to read contract artifacts:
94929492

94939493
```js title="scripts/deploy.js"
@@ -9519,14 +9519,15 @@ const getByteCode = (contractName) => {
95199519
`Could not find bytecode for contract ${contractName}:`,
95209520
error.message,
95219521
);
9522+
throw error;
9523+
}
9524+
};
95229525
```
95239526

95249527
4. Create the main deployment function:
95259528

95269529
```js title="scripts/deploy.js"
9527-
};
9528-
9529-
const deployContract = async (contractName, mnemonic, providerConfig) => {
9530+
const deployContract = async (contractName, mnemonic, providerConfig) => {
95309531
console.log(`Deploying ${contractName}...`);
95319532

95329533
try {
@@ -9559,18 +9560,22 @@ const deployContract = async (contractName, mnemonic, providerConfig) => {
95599560
addresses[contractName] = address;
95609561
writeFileSync(addressesFile, JSON.stringify(addresses, null, 2), 'utf8');
95619562
} catch (error) {
9563+
console.error(`Failed to deploy contract ${contractName}:`, error);
9564+
}
9565+
};
95629566
```
95639567

95649568
5. Configure and execute the deployment:
95659569

95669570
```js title="scripts/deploy.js"
9567-
};
9568-
9569-
const providerConfig = {
9570-
rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
9571+
rpc: 'https://testnet-passet-hub-eth-rpc.polkadot.io',
95719572
chainId: 420420422,
95729573
name: 'polkadot-hub-testnet',
95739574
};
9575+
9576+
const mnemonic = 'INSERT_MNEMONIC';
9577+
9578+
deployContract('Storage', mnemonic, providerConfig);
95749579
```
95759580

95769581
!!! note

0 commit comments

Comments
 (0)