Concordium / concordium-rust-smart-contracts

Libraries and tools for writing and testing smart contracts on Concordium
https://docs.rs/concordium-std/latest/concordium_std/
Mozilla Public License 2.0
57 stars 35 forks source link

Sponsored Transaction enabled auction #367

Closed DOBEN closed 9 months ago

DOBEN commented 11 months ago

Task description

Motivation: Some use cases came with the request to have an example of how to implement a sponsored transaction mechanism on a CIS2 token so that the CIS2 token can be used as a payment token (without acquiring any CCD from an exchange to cover transaction fees).

Some scenarios requested:

The task is to have a simple auction dApp that can hold several items. Everyone can create an item to be auctioned. Users can bid for an item by paying with a given cis2Token via the sponsored transaction mechanism.

Sub-tasks Smart contract state layout:

 items: mapping (u16 -> ItemState)
 cis2_contract: ContractAddress,
 itemCounter: u16,

Smart contract ItemState(state (e.g. sold, active), highest_bidder, highest_bid, item_name, endTime, startTime):

Functions in auction contract:

Additional modification in the cis2-token contract:

Front end + Back end part of dApp:

limemloh commented 11 months ago

To me, it seems the bid entry point is not really needed, since onCis2Received is the entry point for making the bidding. Users can use permit or transfer directly on the token contract instead.

DOBEN commented 11 months ago

@limemloh The bid and onCis2Received entry points were consolidated into one entry point.