Skip to content

Commit 4ba8eae

Browse files
committed
fix: feedback
1 parent 11b9708 commit 4ba8eae

File tree

1 file changed

+15
-27
lines changed
  • develop/smart-contracts/evm-toolkit/libraries

1 file changed

+15
-27
lines changed

develop/smart-contracts/evm-toolkit/libraries/web3-js.md

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,19 @@ npm install web3
2929

3030
The provider configuration is the foundation of any Web3.js application. The following example establishes a connection to the Asset Hub network. To use the example script, replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, and `INSERT_CHAIN_NAME` with the appropriate values. For example, for Westend Asset Hub testnet, use these specific connection parameters:
3131

32-
```js
33-
const PROVIDER_RPC = {
34-
rpc: 'https://westend-asset-hub-eth-rpc.polkadot.io',
35-
chainId: 420420421,
36-
name: 'westend-asset-hub'
37-
};
38-
```
32+
```js
33+
const PROVIDER_RPC = {
34+
rpc: 'https://westend-asset-hub-eth-rpc.polkadot.io',
35+
chainId: 420420421,
36+
name: 'westend-asset-hub'
37+
};
38+
```
39+
40+
The provider connection script should look something like:
3941

4042
```javascript title="connectToProvider.js"
4143
--8<-- 'code/develop/smart-contracts/evm-toolkit/libraries/web3-js/connectToProvider.js'
4244
```
43-
44-
!!! note
45-
Replace `INSERT_RPC_URL`, `INSERT_CHAIN_ID`, and `INSERT_CHAIN_NAME` with the appropriate values. For example, For Westend Asset Hub testnet, use these specific connection parameters:
46-
47-
```js
48-
const PROVIDER_RPC = {
49-
rpc: 'https://westend-asset-hub-eth-rpc.polkadot.io',
50-
chainId: 420420421,
51-
name: 'westend-asset-hub'
52-
};
53-
```
54-
5545
With the Web3 provider set up, you can start querying the blockchain.
5646

5747
For instance, to fetch the latest block number of the chain, you can use the following code snippet:
@@ -86,24 +76,22 @@ After compilation, you'll have two key files: an ABI (`.json`) file, which provi
8676

8777
## Contract Deployment
8878

89-
To deploy your compiled contract to Asset Hub using Web3.js, you'll need an account with a private key to sign the deployment transaction. The deployment process is exactly the same as for any EVM-compatible chain, involving creating a contract instance, estimating gas, and sending a deployment transaction. Here's how to deploy the contract:
79+
To deploy your compiled contract to Asset Hub using Web3.js, you'll need an account with a private key to sign the deployment transaction. The deployment process is exactly the same as for any EVM-compatible chain, involving creating a contract instance, estimating gas, and sending a deployment transaction. Here's how to deploy the contract, ensure replacing the `INSERT_RPC_URL`, `INSERT_PRIVATE_KEY`, and `INSERT_CONTRACT_NAME` with the appropriate values:
9080

9181
```javascript title="deploy.js"
9282
--8<-- 'code/develop/smart-contracts/evm-toolkit/libraries/web3-js/deploy.js'
9383
```
94-
95-
Replace `INSERT_RPC_URL`, `INSERT_PRIVATE_KEY`, and `INSERT_CONTRACT_NAME` with the appropriate values.
96-
9784
## Interact with the Contract
9885

99-
Once deployed, you can interact with your contract using Web3.js methods. Here's how to set a number and read it back:
86+
Once deployed, you can interact with your contract using Web3.js methods. Here's how to set a number and read it back, ensure replacing `INSERT_RPC_URL`, `INSERT_PRIVATE_KEY`, and `INSERT_CONTRACT_ADDRESS` with the appropriate values:
10087

10188
```javascript title="updateStorage.js"
10289
--8<-- 'code/develop/smart-contracts/evm-toolkit/libraries/web3-js/updateStorage.js'
10390
```
10491

105-
Replace `INSERT_RPC_URL`, `INSERT_PRIVATE_KEY`, and `INSERT_CONTRACT_ADDRESS` with the appropriate values.
92+
## Where to Go Next
10693

107-
## Conclusion
94+
Now that you’ve learned how to use Web3.js with Asset Hub, explore more advanced topics:
10895

109-
This guide demonstrates how to use Web3.js to interact with the Asset Hub chain, from setting up a provider to deploying and interacting with smart contracts. By leveraging tools like `@parity/revive` for PolkaVM bytecode compilation and Web3.js for blockchain interaction, developers can seamlessly build and manage dApps within the Asset Hub ecosystem.
96+
- Utilize Web3.js utilities – learn about additional [Web3.js](https://docs.web3js.org/){target=\_blank} features such as signing transactions, managing wallets, and subscribing to events
97+
- Build full-stack dApps – [integrate Web3.js](https://docs.web3js.org/guides/dapps/intermediate-dapp){target=\_blank} with different libraries and frameworks to build decentralized web applications

0 commit comments

Comments
 (0)