Tag: web3js web3

调用合同方法并手动签名时出错。 SendTransaction工作SendRawTransaction不工作

美好的一天, 即时通讯编写节点API暴露我的区块链(部署和松露testing)的方法。 我使用web3.js,ethereumjs-tx,ethereum,松露和坚实作为我的技术堆栈。 var txMethodData = masterKeyContract.myMethod.getData(myParams); 交易参数是: const txParams = { nonce: web3.toHex(web3.eth.getTransactionCount(web3.eth.coinbase)), gasPrice: web3.toHex(web3.eth.gasPrice), gasLimit: web3.toHex(2000000), from: mainAccount, value: '0x00', to: targetContract.address, data: txMethodData, chainId: 3 }; 即时通讯使用ethereumjs-TX const EthereumTx = require('ethereumjs-tx'); 使用链接到我的mainAccount的私钥签署交易 const tx = new EthereumTx(txParams); tx.sign(privateKey); const serializedTx = tx.serialize(); web3.eth.sendRawTransaction("0x" + serializedTx.toString('hex'), function (err1, resp1) { if (err1) { […]