I have a method, where I'm getting an object from another contract, then I'm adding msg.value to the one of the field of this object and then I'm just update this value:
function doVote(uint voteID, address voteFor)
external
payable
valueIsEnough
{
IVoteStorager.VoteData memory voteData = voteStorager.getVote(voteID);
// some not important code
voteData.pool += msg.value;
// some not important code
voteStorager.updateVote(voteID, voteData);
}
updateVote method actually pretty simple:
function updateVote(uint voteID, VoteData calldata vote) external voteIsExists(voteID) override {
votes[voteID] = vote;
}
And when I'm calling this method (I use web3.js) I'm getting an error:
Error: Returned error: VM Exception while processing transaction: revert
When I change voteData.pool += msg.value; on the voteData.pool += 123; everything is works fine. I guess it is problem because of how I'm sending value. I use this:
const gasAmount = await contract.methods.doVote(taskArgs.voteId, taskArgs.participant).estimateGas({from: signer.address});
await contract.methods.doVote(taskArgs.voteId, taskArgs.participant)
.send({
from: signer.address,
gas: gasAmount,
value: 100
})
But also seems like everything is fine here also. Could anybody help me guys? I'm trying to fix it whole day and I can't find any info about this. Thanks!
try it on remix and see if it works there. if it does, then the problem is in your js script
Обсуждают сегодня