I am using infura kovan with nodejs and web3 v1.0.0-beta55
Sending transactions using sendSignedTransaction returns the error
{“code”:-32602,“message”:“invalid arguments to eth_getBlockByNumber”}
This happens only in about 3 of 10 times tried.
I am adding a code snipped to reproduce this here. It will create new tx and send them 10 times and count how many will show the error.
const EthereumTx = require(‘ethereumjs-tx’).Transaction;
const web3eth = require(‘web3-eth’);const eth = new web3eth.Eth(‘https://kovan.infura.io/v3/REMOVED’, null);
const eth_priv_key_seed = “REMOVED”
const eth_priv_key = Buffer.from(eth_priv_key_seed, ‘hex’)loop();
global.good = 0;
global.bad = 0;async function loop() {
var nonce = (await eth.getTransactionCount(‘SENDING_ADDRESS’));
for (let i = 0; i < 10; i+= 1) {
await sendPayment(nonce);
nonce += 1;
}
console.log(‘good:’, good, ‘bad:’, bad);
}async function sendPayment(nonce) {
const payment = {
nonce: nonce,
gasPrice: ‘0x1000000000’,
gasLimit: ‘0xcf08’,
to: ‘RECEIVING_ADDRESS’,
from: ‘SENDING_ADDRESS’,
value: ‘0x0000000000001’,
chainId: 42,
amount: ‘0x0000000000001’,
}
console.log(payment);
const tx = new EthereumTx(payment);
tx.sign(eth_priv_key);
const serializedTx = “0x”+tx.serialize().toString(“hex”);
console.log(serializedTx);
try {
let res = await eth.sendSignedTransaction(serializedTx);
console.log(res);
good += 1;
}
catch (err) {
console.log(err);
bad += 1;
}
}