5

My question is about the blind auction contract in the solidity examples.

What is the right way to interact with the contract from web3.js? I tried this, but it does not give the right result.

var blinded_bid = web3.sha3(10, true, "abcd");

It would be great if someone could provide an example how to interact with that kind of contract using web3.

  • A little more code of what you tried would be helpful, such as how's the contract instantiated and how are you invoking the bid method? – eth Feb 4 '16 at 11:36
  • Did you deploy the contract yet? – Waqar Lim Feb 6 '16 at 23:26
  • Uzyn, how is you answer sending funds to the bid() function ? – Ilan Jan 16 '18 at 19:51
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – flygoing Jan 16 '18 at 20:38
  • Thank you, I know but I cannot comment on Uzyn's post – Ilan Jan 16 '18 at 20:41
2

For the contract that you are referring to, it involves 2 steps to make a bid:

  1. First you hash your bid so that public cannot see your bid, but you can reveal and the contract can validate it after the bidding ends. This is done via sha3() call as what you have done.
  2. Next, you submit the bid to the contract via the method bid(bytes32 _blindedBid).

Here is sample code in JavaScript with web3:

// Instantiate the contract
var ABI = ...; // ABI of the contract
var address = '0x.............'; // Address of the contract
var contract = web3.eth.contract(ABI).at(address);

// Step 1. Hash your bid
var blindedBid = sha3(10, true, 'abcd');

// Step 2: Submit the bid
web3.eth.defaultAccount = web3.eth.accounts[0]; // Set a default account to send from
contract.bid(blindedBid);

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.