web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

non-supported RPC methods guide

Open SantiagoDevRel opened this issue 2 years ago • 0 comments

2024 H1 Action Items: Expand web3.js documentation with 5 guides explaining common usage and/or best practices

References:

  • Create a guide (it can be under the advance category, to add the functionality of web3.extend to use it for other RPC methods
  • Add code samples with common RPC methods not supported by web3.js but supported by some ethereum clients like geth, nethermind, besu, erigon, etc
  • The code samples can be done using the web3.extend() function, but using plugins samples would be highly appreciated
  • Example eth_getBlockReceipts()
  • add a note to encourage use of plugins instead of web3.extend
const { Web3 } = require("web3");

const web3 = new Web3(
  "https://nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7"
);

async function main() {
  web3.extend({
    property: "L2Module",
    methods: [
      {
        name: "getBlockReceipts",
        call: "eth_getBlockReceipts",
      },
    ],
  });

  const receipts = await web3.L2Module.getBlockReceipts("latest"); //return all the receipts
  console.log(receipts);
}

main();
  • This can be added either in 🧠 Advanced category or 🧩🛠️ Web3 Plugin section

SantiagoDevRel avatar Jan 28 '24 14:01 SantiagoDevRel