I have a smart contract for selling Painting in crowdsale, Once the Painting is sold in crowdsale the owner of the painting can trade it to other user once the crowdsale is over. I have to implement a buy function where the buyer can buy the painting only if the seller has interest to sell it.The problem I am facing is that How can a buyer know whether the seller is interested and at what cost is he comfortable to sell? Once solution I have thought is that to make the function multisig where both buyer and seller need to sign to transfer the painting and accept the Payment.

Ps :- How to implement multisig feature to a function to sign

  • 1
    How about just a setPrice (callable by the seller) and buy (callable by the buyer)?
    – user19510
    May 26, 2018 at 5:18
  • The Price will already be set when the token is being purchased by the first buyer(i.e seller ) . But what if the seller don't have interest to sell the painting. can I have a mapping for the interest to sell?? And then by using that mapping we can know the seller intent.
    – Sarvottam
    May 26, 2018 at 5:23
  • Then they can call setPrice(2**256-1).
    – user19510
    May 26, 2018 at 5:24
  • No I cannot set the price as 0 because the painting has to be sold at price greater than the price it was purchased and the platform will get commission on that sell.
    – Sarvottam
    May 26, 2018 at 5:29
  • I'll just delete that comment, as it seems to have confused you.
    – user19510
    May 26, 2018 at 5:30

1 Answer 1


Assume the painting ownerships are stored in a mapping, you can create, another mapping where the owner set if he wants to sell it or not, for instance:

mapping(address => uint256) public paintingOwnership; // this assumes the painting id is a number
mapping(uint256 => bool) public sellStatus;

function buy(uint256 paintingID) public {
    require(sellStatus[paintingID],"Painting is not for sale")
    // do here the required to make the transaction between tokens/ether and the painting

function changeSellStatus(bool value) public {
    require(paintingOwnership[msg.sender] > 0);
    uint paintingID = paintingOwnership[msg.sender];
    sellStatus[paintingId] = value;

function availability(uint256 paintingID) public pure returns(bool){
    return sellStatus[paintingId];

The function buy will be executed by the buyer and will only be executed if the painting is for sell. Buyers can also check availablity with the function provided. The seller will use changeSellStatus to set if they want to sell (True) or not (False).

Hope this helps.

  • Exactly, I was also thinking of the same. Thanks for clearing the air.
    – Sarvottam
    May 26, 2018 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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