0

Truffle 経由で生のトランザクションをガナッシュに送信しようとしています。エラー メッセージ「Object.exports.toBuffer の型が無効です」。

コードは次のとおりです。

const Tx = require('ethereumjs-tx').Transaction;
const privateKey = Buffer.from('5b58ae3fe5bf48d05f0a94c87a28fb480ec2bc200a4423ab42ea9557f3617743', 'hex');

const payment_usercashTx = {
    nonce: myAsyncNonceFunction(),
    gasPrice: web3.utils.toHex(25000),
    gasLimit: web3.utils.toHex(10e9),
    to: '0x107180312267DB452930731EA475187BdD4948DB',
    from: web3.eth.defaultAccount,
    value: '0x00',
    data: encode_usercash
}

let usercashTx = new Tx(payment_usercashTx);
usercashTx.sign(privateKey);

let usercash_serializedTx = usercashTx.serialize();

web3.eth.sendSignedTransaction('0x' + usercash_serializedTx.toString('hex'))
.on('receipt', console.log);

新しいメッセージ:

Error: invalid type
    at Object.exports.toBuffer (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/bytes.js:97:19)
    at Transaction.setter [as nonce] (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/object.js:43:25)
    at /Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/object.js:96:38
    at Array.forEach (<anonymous>)
    at Object.exports.defineProperties (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-util/dist/object.js:94:20)
    at new Transaction (/Users/yuha/Desktop/blockchainProject/Kidari/node_modules/ethereumjs-tx/dist/transaction.js:127:27)
    at Object.<anonymous> (/Users/yuha/Desktop/blockchainProject/Kidari/routes/payment.js:72:18)
4

0 に答える 0