CRYPTO NEWS

How to call a contract’s method via web3 1.x without a node (sign with a privateKey and send)?

There’s a number of questions and answers about calling contract methods via web3, but they are either outdated (i.e. for web3 0.x while 1.x has many breaking changes) and/or don’t include signing (1, 2, 3). The first steps, as far as I understand, should be these:

import Web3 from "web3" import { AbiItem } from "web3-utils"  ;(async() => {     const provider = new Web3.providers.HttpProvider(...)     const web3 = new Web3(provider)      // see https://ethereum.stackexchange.com/a/98149/40080 and https://github.com/ChainSafe/web3.js/issues/3310#issuecomment-997396686     const abi = ... as AbiItem[] // imported from a file     const methodName = ...     const callParameters = [         ...     ]     const contractAddress = ...     const universeContract = new web3.eth.Contract(abi, contractAddress)      const call = universeContract.methods[methodName](callParameters) })() 

but then I also have to sign this with private key and send, and this is what I haven’t achieved yet. According to this answer, I should be using eth.accounts.sign(data, privateKey) (since I have to do this without a node), but I have no idea what data I should extract from call and how (and how to further send it). Can somebody show how to do this or at least give some pointers?

How to call a contract’s method via web3 1.x without a node (sign with a privateKey and send)?

Shopping cart
There are no products in the cart!
Continue shopping
0