From the ABI in a VueJS frontend I'm trying to trigger the following method in my contract:

// Payout.sol

function checkStatusAndPay(bytes32 _gameId, int _winner) public notDisabled onlyOwner returns (bool _paid)  {
  // does some checkings and then transfers ethers to registered addresses

I'm using this:

// payout_service.js

const contract = new ethers.Contract(contractAddress, abi, signer);
const transaction = await contract.checkStatusAndPay(id, winner);

And also tried the same code adding some hardcoded value:

const transaction = await signerContract.checkStatusAndPay(id, winner, { value: "0.02" });

But I keep getting this error:

Error: invalid BigNumber value (argument="value", value={"isTrusted":true}, code=INVALID_ARGUMENT, version=bignumber/5.4.1)

*Not sure it plays a part here, but I'm using MetaMask wallet


It works fine in tests, I'm using hardhat:

describe("Payout", function() {
    before(async function () {
        Payout = await ethers.getContractFactory("Payout");
        [owner, user1, user2, user3] = await ethers.getSigners();

        contract = await Payout.deploy();

      it("pays prizes to each winner", async function() {
          const tx = await contract.checkStatusAndPay(game, 2);
          // check emited events content
          const res = await tx.wait();
          // check values in broadcasted events for first winner user1
          expect(res.events[0].args.message).to.equal("Prize sent to user address");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.