Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/auctions #39

Merged
merged 4 commits into from
Oct 11, 2024
Merged

Feat/auctions #39

merged 4 commits into from
Oct 11, 2024

Conversation

oceans404
Copy link
Member

New Nada Example: Auctions

Description

I added 2 new examples that show how to write a Nada auction program. Each of these has a streamlit app (within streamlit_demo_apps) to demonstrate usage.

  • auction.py is a simple auction that does not handle the tie edge case. If 2 bidders submit the same highest bid, the bidder who submitted first wins.
  • auction_can_tie.py handles the tie edge case by returning the top bid and a flag list telling you if a party submitted a bid that matches the top bid.

Use Case

What are the target use cases for the example?
blind auctions

Related Issues

Link to the related issue if this PR solves an Issue.
N/A

Optional: add your information for a Nada by Example Contributor POAP

Your Twitter: 0ceans404
Your Ethereum address: oceans404.eth

# Create a list of outputs for each bidder, indicating if their bid matches the highest bid
# Each output is a flag (1 if the bid matches the highest bid, 0 otherwise), visible to the auctioneer
flag_highest_bid = [
Output((bids[i] == highest_bid).if_else(Integer(1), Integer(0)), f"bidder_{i}_flag_highest_bid", auctioneer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

]

# Return the highest bid and a list of flags indicating which bidders flag the highest bid
return [Output(highest_bid, "highest_bid", auctioneer)] + flag_highest_bid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the + here concatenation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is so that the outputs of the highest_bid and all the individual bid result flags are returned

@oceans404 oceans404 merged commit 698183e into main Oct 11, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants