-
Notifications
You must be signed in to change notification settings - Fork 1
Marketplace contract
alexaunter edited this page Jan 23, 2022
·
31 revisions
Roles of accounts in this example:
- marketplace account - test_nearnames.testnet
- lot - account being sold at auction - alice.test_nearnames.testnet
- seller - receiver of rewards paid by bidders - bob.test_nearnames.testnet
- bidder - anyone who places the bid on the lot - carol.test_nearnames.testnet
- buyer - bidder that made the last bid and wins the auction
- claimer - account that gains access to lot account
- alice calls marketplace lot_offer method
- alice deploys and initializes lock contract, removes all access keys
- carol views marketplace lot_list method, sees alice account
- carol ensures that alice is safe to buy account
- carol calls marketplace lot_bid method
- auction ends, because ending conditions are met
- carol calls marketplace lot_claim method to gain access to the account
- bob views marketplace profile_get to check amount of available rewards
- bob calls marketplace profile_rewards_claim method to gain rewards buyer paid


- alice calls marketplace lot_offer method
- alice deploys escrow contract, removes all access keys
- bob reconsiders, doesn't want to sell account anymore
- bob calls marketplace lot_withdraw method, noone can make bids after that
- bob calls marketplace lot_claim method to gain access to the account
- bob gets no rewards, since there were no bids

To ensure that buyer will receive control of account after auction finish, we require lot to be configured in a way that doesn't allow the buyer to regain access to it during and/or after the auction.
The requirements are the following:
- The account deployed contract with code_hash of our lock contract
- The account doesn't have any access keys
- The account owner (account that can add keys) is marketplace account
Auction ends by reaching any of the following conditions:
- time_now > lot_offer call time + auction duration
- there exists a bid with amount >= buy_now price
Marketplace contract call lot_offer and lock deploy#Checking configuration