1

I have the following function in my contract:

  function proposeMedia (string[] memory addresses) public {
    require(block.timestamp < expires);
    require(hashCompareWithLengthCheck(status, 'open'));
    require(payable(msg.sender) == platform);
    reporter =  payable(msg.sender);
    mediaAddresses = addresses;
    status = 'proposed';
  }

I can send an array of strings to the contract via Remix, which works fine. But it errors when I pass the array via Web3js, like this:

const addresses = ['media1', 'media2']
await contract.methods.proposeMedia(addresses)
  .send({
    from: accounts[2],
    gas: '8000000'
  })

Am I missing something about the way Web3 passes string arrays?

1 Answer 1

0

The issue here was just that I'd left a check from a previous iteration in here and it was causing the function to revert.

require(payable(msg.sender) == platform);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.