Arbitrum Stylus logo

Stylus by Example

English Auction

An Arbitrum Stylus version implementation of Solidity English Auction.

Auction

  1. Seller of NFT deploys this contract.
  2. Auction lasts for 7 days.
  3. Participants can bid by depositing ETH greater than the current highest bidder.
  4. All bidders can withdraw their bid if it is not the current highest bid.

After the auction

  1. Highest bidder becomes the new owner of NFT.
  2. The seller receives the highest bid of ETH.

Here is the interface for English Auction.

1interface IEnglishAuction {
2    function nft() external view returns (address);
3
4    function nftId() external view returns (uint256);
5
6    function seller() external view returns (address);
7
8    function endAt() external view returns (uint256);
9
10    function started() external view returns (bool);
11
12    function ended() external view returns (bool);
13
14    function highestBidder() external view returns (address);
15
16    function highestBid() external view returns (uint256);
17
18    function bids(address bidder) external view returns (uint256);
19
20    function initialize(address nft, uint256 nft_id, uint256 starting_bid) external;
21
22    function start() external;
23
24    function bid() external payable;
25
26    function withdraw() external;
27
28    function end() external;
29
30    error AlreadyInitialized();
31
32    error AlreadyStarted();
33
34    error NotSeller();
35
36    error AuctionEnded();
37
38    error BidTooLow();
39
40    error NotStarted();
41
42    error NotEnded();
43}
1interface IEnglishAuction {
2    function nft() external view returns (address);
3
4    function nftId() external view returns (uint256);
5
6    function seller() external view returns (address);
7
8    function endAt() external view returns (uint256);
9
10    function started() external view returns (bool);
11
12    function ended() external view returns (bool);
13
14    function highestBidder() external view returns (address);
15
16    function highestBid() external view returns (uint256);
17
18    function bids(address bidder) external view returns (uint256);
19
20    function initialize(address nft, uint256 nft_id, uint256 starting_bid) external;
21
22    function start() external;
23
24    function bid() external payable;
25
26    function withdraw() external;
27
28    function end() external;
29
30    error AlreadyInitialized();
31
32    error AlreadyStarted();
33
34    error NotSeller();
35
36    error AuctionEnded();
37
38    error BidTooLow();
39
40    error NotStarted();
41
42    error NotEnded();
43}

Example implementation of a English Auction contract written in Rust.

src/lib.rs

1Loading...
1Loading...

Cargo.toml

1Loading...
1Loading...