In blind auctions from solidity documentation what value should I insert under the bid function?Even I inserted string value,integer value under the bid function but it is showing the error as invalid value..enter image description here..

  • It is better to include the code as text that way it is easier to copy and test.
    – Ismael
    Jan 18 at 4:12

You can look at the function's parameters bid(bytes32 _blindedBid), it's a bytes32 type. An example of a valid bytes32 value is 0x6b5fc80c91d15ca5b4cf5b965ce20114777022aec8a50912bacde96a9558b22e. But yeah, you need to pass in a bytes32 value that makes sense to you.

You can find some comments written above the bid function in the code, they are to guide you through this. Let's see what's there:

    /// Place a blinded bid with `_blindedBid` =
    /// keccak256(abi.encodePacked(value, fake, secret)).
    /// The sent ether is only refunded if the bid is correctly
    /// revealed in the revealing phase. The bid is valid if the
    /// ether sent together with the bid is at least "value" and
    /// "fake" is not true. Setting "fake" to true and sending
    /// not the exact amount are ways to hide the real bid but
    /// still make the required deposit. The same address can
    /// place multiple bids.
    function bid(bytes32 _blindedBid)
            blindedBid: _blindedBid,
            deposit: msg.value

I generally use ethersjs to do the hashing and abi encoding/decoding stuff. But here, since you are using remix, I'd suggest to add this function to your solidity code:

function generateBlindedBidBytes32(uint256 value, bool fake, bytes32 secret) public view returns (bytes32) {
    return keccak256(abi.encodePacked(value, fake, secret));

This helper function simply encodes your bid amount into a blinded bid bytes32 value, which you can pass to the bid function. Use this function from remix just to prepare your blinded bid. The first argument value is the amount of wei. Second argument fake, set it as false if you want that bid to not be a fake bid. Third argument secret, pass any random bytes32 value from somewhere on the internet (my quick source of bytes32 value is etherscan's latest transaction hashes).


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.