let gasPrice = await web3.eth.getGasPrice().then(price => {return price});
let currentAccount = "0xd8A8e71CE21523A490ceeB75026585822BB7e92D";
let nonce = await web3.eth.getTransactionCount(currentAccount).then(nonce => {return nonce});
nonce += 1;
let Txdata = {
nonce: web3.utils.toHex(nonce),
gasLimit: web3.utils.toHex(23000),
gasPrice: web3.utils.toHex(gasPrice),
to: contractAddress,
from: currentAccount,
value: '0x00',
data: "0xa9059cbb00000000000000000000000017da548fe1485718478c79269661de85851de1240000000000000000000000000000000000000000000000000000000005f5e100"
};
let hash = new Tx(Txdata);
const privateKey = Buffer.from(currentAccountPrivateKey, 'hex');
hash.sign(privateKey);
let serialized = hash.serialize();
web3.eth.sendSignedTransaction('0x' + serialized.toString('hex'), (err, tx) => {
if (!err) {
console.log(tx);
} else {
console.error(err);
}
});
let gasPrice = await web3.eth.getGasPrice().then(price => {return price});
let currentAccount = "0xd8A8e71CE21523A490ceeB75026585822BB7e92D";
let nonce = await web3.eth.getTransactionCount(currentAccount).then(nonce => {return nonce});
let Txdata = {
nonce: web3.utils.toHex(nonce),
gasLimit: web3.utils.toHex(23000),
gasPrice: web3.utils.toHex(gasPrice),
to: contractAddress,
from: currentAccount,
value: '0x00',
data: "0xa9059cbb00000000000000000000000017da548fe1485718478c79269661de85851de1240000000000000000000000000000000000000000000000000000000005f5e100"
};
let hash = new Tx(Txdata);
const privateKey = Buffer.from(currentAccountPrivateKey, 'hex');
hash.sign(privateKey);
let serialized = hash.serialize();
web3.eth.sendSignedTransaction('0x' + serialized.toString('hex'), (err, tx) => {
if (!err) {
console.log(tx);
} else {
console.error(err);
}
});
Hello @asd2e, same problem here with sendSignedTransaction.
It happen when
- Gas price is too low
- require is not succed in smartcontract
In a way, I think it’s about “revert” transaction problem with signedTransaction.
Did you solve the problem ?
Cheers.