Tag: ethereum web3js

发送原始交易以太坊infura nodejs npm

我目前正试图实现以太坊节点连接到我的手稿/节点项目。 我连接到“Infura”节点服务器,我需要在本地签署我的事务。 好吧,无论如何。 我正在使用npm包“ethereumjs-tx”签署我的交易,一切看起来都很棒。 当我从web3使用“sendRawTransaction”时,我的回应是一个tx-id,这意味着我的交易应该已经在区块链中。 呃…不是 我的符号交易function如下。 private signTransactionLocally(amountInWei: number, to: string, privateKey: string = <PRIVATE_KEY>, wallet: string = <MY_WALLET>) { const pKeyBuffer = Buffer.from(privateKey, "hex"); const txParams = { nonce: this.getNonce(true,wallet), //gas: this.getGasPrice(true), gasLimit: this.getGasLimit2(true), to: to, value: amountInWei, data: '0x000000000000000000000000000000000000000000000000000000000000000000000000', chainId: "0x1" }; // console.log(JSON.stringify(txParams)); const tx = new this.ethereumTx(txParams); tx.sign(pKeyBuffer); return tx.serialize().toString("hex"); […]