So I'm trying to send a transaction on BSC (testnet) with nodejs web3 (bep-20).
After sending via the contract with web3 I only get a TX hash as a response and no receipt or anything like that. When I search for the transaction on the blockchain it doesn't exist. But then when trying to send another transaction and I get an error INTERNAL_ERROR: could not replace existing tx
.
It works if I change the nonce but then again I only get the TX has h returned which doesn't exist.
Also, no funds get spent from my address.
My code:
const contract = new web3.eth.Contract(abiJson, contract_address, { gasPrice: "51067" });
await contract.methods.transfer(receiver_address, 10000000).send({
from: sender_address,
gas: 21596,
nonce: 0,
})
.on("transactionHash", function (hash) {
console.log(hash);
})
.on("confirmation", function (confirmationNumber, receipt) {
console.log(confirmationNumber, receipt);
})
.on("receipt", function (receipt) {
// receipt example
console.log(receipt);
})
.on("error", function (error, receipt) {
console.log(error, receipt);
})
Returned TX hash example:
0x0ac1c9e3ad108068f953299c82343057d2e739fab9801e897b25d53170fe3ff0
UPDATE
when I use web3.eth.getTransaction(txHash);
I get the following:
{
blockHash: null,
blockNumber: null,
from: '0x5de622df348974877Cf7108785f67e09b97785Fc',
gas: 21596,
gasPrice: '51067',
hash: '0x0ac1c9e3ad108068f953299c82343057d2e739fab9801e897b25d53170fe3ff0', input: '0xa9059cbb000000000000000000000000ff3b0833aab74477d5efa1665632709cc8e2e0f800000000000000000000000000000000000000000000000000000000000186a0',
nonce: 4,
to: '0x337610d27c682E347C9cD60BD4b3b107C9d34dDd',
transactionIndex: null,
value: '0',
type: 0,
v: '0xe5',
r: '0x2a0c5365fff32a2314ab1aee0847aa7202b5cdd8f5e070df162e47b7e9ed65a5',
s: '0x4415513033acb12a484498252b8247d8f33bbb80d5093f77df4d2c515744dde7'
}
Still, I don't understand why the TX isn't going live.