let incrementInstance = new web3.eth.Contract(abi, "0xAdD6C000C32c1A672f252fFf458e366948921C97"); let initNum = await incrementInstance.methods.getNumber().call(); console.log("当前初始化值是" + initNum);
console.log("通过调用合约的自增方法来给合约num附上新值"); const newValue = 2024; console.log(newValue); let incrementTx01 = incrementInstance.methods.increment(newValue); let incrementTransation = await web3.eth.accounts.signTransaction({ to: "0xAdD6C000C32c1A672f252fFf458e366948921C97", data: incrementTx01.encodeABI(), gas:8000000, }, account_from.privateKey ) // const incrementRes = await web3.eth.sendSignedTransaction(incrementTransation.rawTransaction); // console.log('Tx successful with hash ' + incrementRes.transactionHash);
console.log("调用reset方法发出的事件"); let incrementTx02 = incrementInstance.methods.reset(); let incrementTransation02 = await web3.eth.accounts.signTransaction({ to: "0xAdD6C000C32c1A672f252fFf458e366948921C97", data: incrementTx02.encodeABI(), gas:8000000, }, account_from.privateKey ) // const incrementRes = await web3.eth.sendSignedTransaction(incrementTransation02.rawTransaction);