I don't know why this transaction fails:
https://testnet.bscscan.com/tx/0xe464a4bb94268c97c0e5f795f6fb336d982c1570c426e8518266875515d42a76
It's called like this:
const contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);
const value = web3.utils.toWei('0.01', 'ether'); // Define how much ether you want to send.
const fromAddress = accounts[0];
// Create a transaction object
const tx = {
from: fromAddress,
value: value, // This sends 0.1 Ether along with the transaction
gas: 3000000, // Adjust the gas limit as needed
};
contract.methods.addPlayer('PAID').send(tx)
// first we receive the transaction hash
.on('transactionHash', (hash) => {
console.log("hash received");
console.log(hash);
})
If I make this call directly from online Remix, it works flawlessly. Like here: https://testnet.bscscan.com/tx/0xd8d3004ad3b63e6ffaff50323086af24fa30a52f01777eb6290356f12ee8373f
I noticed there is a difference in input data in the details of the transaction. Yet contract method is called correctly.
Any ideas? Thanks, Jure
Funny enough. The code was allright.
I downgraded web3 version from 4.1.1 to 4.0.3 and it started working. Thanks to you all!