Beta
FIFO-like waiting list smart contract
18fylkir
Description:
Let's create a smart contract with a FIFO queue-like interface that may serve as a simple waiting list.
Requirements:
- The user should be able to add themselves (i.e. their address) to the end of the queue by calling the
push
method. It should take no arguments. - A deposit of at least 0.1 ether is required for a push operation to succeed. The deposit should be kept by the contract and be returned to user on
pop
(see point 5.) - The contract should keep the number of items in the queue and serve it via
size()
method. - All items in the queue should be accessible via
get
method. It should take the index of an item as an argument and return the tuple containing address and deposit size. Trying to get an item from an empty queue should revert. Getting an item with non-existing index should also revert. - Calling the
pop
method should remove an item from the front of the queue. It should be callable only by the contract owner. Upon calling the method the deposit made by the user onpush
should be returned to them in the exact same amount. Popping an empty queue should revert. - The following gas limits should be met:
operation gas limit push 75000 pop 61000
Summary:
Your task is to implement four interface methods according to the requiremens:
push() external payable
pop() external
size() external view returns(uint256)
get(uint256 _index) external view returns(address, uint256)
Keeping the function signatures as specified above is also a requirement.
Web3
Similar Kata:
Stats:
Created | Oct 18, 2022 |
Published | Oct 19, 2022 |
Warriors Trained | 69 |
Total Skips | 9 |
Total Code Submissions | 506 |
Total Times Completed | 18 |
Solidity Completions | 18 |
Total Stars | 3 |
% of votes with a positive feedback rating | 92% of 6 |
Total "Very Satisfied" Votes | 5 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |