1

I don't understand what should input into bid() function. Whatever I do, it shows the same error:

"Error encoding arguments: Error: invalid arrayify value (argument="value", value="1 true secret", code=INVALID_ARGUMENT, version=bytes/5.0.5)
" 

What am I missing?
Below is the code for the bid() function.

function bid(bytes32 _blindedBid)
        public
        payable
        onlyBefore(biddingEnd)
    {
        bids[msg.sender].push(Bid({
            blindedBid: _blindedBid,
            deposit: msg.value
        }));
    }

enter image description here

2

When declaring a bytes32 type, this forces you to input a value with a fixed length of bytes32. Since your input (in Remix) is shorter, it returns an error.

I haven't seen your struct & mapping declaration, but I am assuming you have the following code:

contract Test {

   struct Bid {
       bytes32 blindedBid;
       uint256 deposit;
   }

   mapping(address => Bid[]) public bids;
 
   function bid(bytes32 _blindedBid)
        public
        payable
    {
        bids[msg.sender].push(Bid({
            blindedBid: _blindedBid,
            deposit: msg.value
        }));
    }
}

Therefore, if you add an entry with bytes32 such as:

0x6c00000000000000000000000000000000000000000000000000000000000000

the function call should work fine. So with Remix, it's a bit tricky to add this kind of data input and you have to do the conversion manually. On the other hand, if you are using a front-end with web3.js, you may use conversions such as:

web3.utils.padRight(web3.utils.fromAscii('hello'), 34)
1

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.