From 69328033601c5a4dd1b3b18cd476d7086068fb30 Mon Sep 17 00:00:00 2001 From: jeremy-then Date: Thu, 30 Jan 2025 14:47:54 -0400 Subject: [PATCH] Removes web3 example. Refactors. --- README.md | 38 ++++++++------------------------------ tools/PrecompiledAbis.html | 11 +++++------ tools/RootstockBridge.html | 2 +- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 0a177b3..470cf77 100644 --- a/README.md +++ b/README.md @@ -24,24 +24,22 @@ For the installation of these package you must execute in a terminal window: npm install @rsksmart/rsk-precompiled-abis@ ``` -## With Ethersjs +## With Ethers ```js const ethers = require('ethers'); const precompiledAbi = require('@rsksmart/rsk-precompiled-abis'); +const networkUrl = 'https://public-node.rsk.co/'; -const BRIDGE_ADDRESS = '0x0000000000000000000000000000000001000006'; -const networkUrl = 'https://public-node.testnet.rsk.co/'; -const bridgeAbi = precompiledAbi.bridge.abi; const provider = new ethers.JsonRpcProvider(networkUrl); -const bridge = new ethers.Contract(BRIDGE_ADDRESS, bridgeAbi, provider); +const bridge = new ethers.Contract(precompiledAbi.bridge.address, precompiledAbi.bridge.abi, provider); bridge.getBtcBlockchainBestChainHeight().then(console.log); ``` -That would print something like: `3633485n`. +That would print something like: `881524n`. ## With Viem @@ -49,10 +47,7 @@ That would print something like: `3633485n`. const { createPublicClient, http } = require("viem"); const { mainnet } = require("viem/chains"); const precompiledAbi = require('@rsksmart/rsk-precompiled-abis'); - -const BRIDGE_ADDRESS = '0x0000000000000000000000000000000001000006'; -const networkUrl = 'https://public-node.testnet.rsk.co/'; -const bridgeAbi = precompiledAbi.bridge.abi; +const networkUrl = 'https://public-node.rsk.co/'; const client = createPublicClient({ chain: mainnet, @@ -62,8 +57,8 @@ const client = createPublicClient({ const getBlockchainHeight = async () => { try { const height = await client.readContract({ - address: BRIDGE_ADDRESS, - abi: bridgeAbi, + address: precompiledAbi.bridge.address, + abi: precompiledAbi.bridge.abi, functionName: "getBtcBlockchainBestChainHeight", }); console.log("btcBlockchainBestChainHeight:", height); @@ -76,24 +71,7 @@ getBlockchainHeight(); ``` -That would print something like: `3633485n`. - -## With Web3 - -```js - -const Web3 = require('web3'); -const precompiledAbi = require('@rsksmart/rsk-precompiled-abis'); -const BRIDGE_ADDRESS = '0x0000000000000000000000000000000001000006'; -const networkUrl = 'https://public-node.testnet.rsk.co/'; -const bridgeAbi = precompiledAbi.bridge.abi; - -const web3 = new Web3(networkUrl); -const bridge = new web3.eth.Contract(bridgeAbi, BRIDGE_ADDRESS); - -bridge.methods.getBtcBlockchainBestChainHeight().call().then(console.log) - -``` +That would print something like: `881524n`. # Important note diff --git a/tools/PrecompiledAbis.html b/tools/PrecompiledAbis.html index b283594..c3aba3d 100644 --- a/tools/PrecompiledAbis.html +++ b/tools/PrecompiledAbis.html @@ -85,8 +85,8 @@
Simple html page to get bridge methods selectors and eve