---
# System prepended metadata

title: Solidity Task

---

# Solidity Task

Your task is to create a simple contract and small locally runnable UI for a [Harberger-taxed](https://en.wikipedia.org/wiki/Arnold_Harberger) data row. Specifications below.

## Contract

### Issuance

The contract puts a "slot" of data for sale, a data row. This slot is owned by the contract issuer on issuance.

The contract issuer defines:

 - initial price (X)
 - tax rate (T)
 - tax period (Q)
 - Harberger hike (H), percentage value
 - token contract address, for which token to use as currency (C)

Post-issuance, the issuer MUST be able to modify all parameters but they MUST apply only once the ownership of the "slot" reverts back to issuer. The issuer should also be able to change issuer to another.

### Sale and Tax

Once the slot is up for sale, anyone can buy it for X. The purchase price can be represented as P, and in the initial sale, P == X. The buyer can define their own price too, higher than the previous.

Anyone else can at any time buy the slot from the current owner at a price of `P + (P * H) + TAX` where `TAX = (P + (P * H) * T)`. TAX is sent to issuer (current owner of the contract, but after escrow, see caveat), and the remainder is sent to the previous owner who just lost the slot. The ownership changes only at the turnover of Q.

Example: assuming Q=7 and the slot was purchased on day 3, the ownership will change in ~4 days. This gives the previous owner ample time to re-buy the slot, should they wish to keep it after all.

The TAX part of every sale is used to retain ownership of the slot for the current Q. Before the current Q elapses and switches to Q+1, the current owner MUST manually trigger a TAX payment, which is again sent to the current owner of the contract (after escrow - see caveats).

If the current owner fails to pay the next Q's TAX, the ownership of the slot reverts to the issuer at the start of Q+1 and the game restarts.

### Caveats

1. Configuration settings must only be modifiable by the issuer if the issuer also owns the slot. For that purpose, the issuer must either wait for an owner to fail at paying the tax, or buy the slot himself. The settings CANNOT be changed while the slot is owned by someone else.

2. The prepaid tax should be held in escrow by the contract. During sale it is refunded if the last buyer is bought out. Otherwise, it is forwarded to the issuer on Q turnover.

## UI

The UI **must** be downloadable and locally runnable, ergo, hostable on something like IPFS. Decentralization is a must. The UI _can_ be developed with modern frameworks and approaches, but should be compiled down into something that does not rely on single points of failure.

As such, the user should be:

- default to a public endpoint
- able to manually input an RPC endpoint
- able to choose to take the RPC endpoint as initiated by their embedded wallet (i.e. metamask injection)

The UI also MUST NOT prompt the user to connect a wallet on page-open, only on interaction. The data, price, and other information should be immediately visible without connecting a wallet.

Mobile-compatibility, UX, design are not a priority, only the interactions with the contract matter.

### UI elements

- view contract params (initial price, tax hike, period, etc.)
- pre-pay tax for next Q button
- renounce ownership (refunds tax prepaid by user + reverts ownership to issuer, restarting the game)
- buy slot button
- change slot value (available for owner, owner can manipulate data stored in slot - simple string)
- time until Q expires

## Full example story

Alice issues the contract with the following settings:

 - initial price (X): 100
 - tax rate (T): 10
 - tax period (Q): 7
 - Harberger hike (H): 10
 - currency is RMRK

1. The slot is up for sale for 100 RMRK.
2. 3 days elapse.
3. Buying it requires at least 120 RMRK: 100 initial price + 10% tax + 10% hike = 120 RMRK
4. Bob buys the slot for 120 RMRK. Due to having paid the tax, this includes a whole next Q.
5. While the current Q is still ongoing, Bob is only the owner "in name" and cannot modify the content. However, others can now buy it from him.
6. No one buys this from Bob, so 4 days later, Bob becomes the owner. He has paid the tax during the initial purchase, so he is at peace for over 6 days. He sets the slot to "Cardano sucks".
8. Charlie is offended by this message, and decides to buy the slot and override the value. 2 days in, he has collected enough funds to actually set the buying price much higher and prevent Bob from re-taking it. He decides to buy the slot for 500 RMRK.
9. A price of 500 is more than the 10% hike, so that is covered. However, the tax is calculated on top of the sale price, which means Charlie is actually paying 550 with the included 10% (50 RMRK) tax for keeping the slot during the next Q. 500 RMRK went to Bob, so he made a tidy profit on his original 120 RMRK investment.
10. Charlie must endure the message for another 5 days. During these 5 days, to reclaim the spot, Bob would now have to pay at least 500 + 10% + 10%, meaning 600 RMRK. While he is richer for having gotten 500 back, he would still have to re-invest almost as much as he originally put in to reclaim it.
11. Gonzo is up for it, though. He knows Charlie just wants to write "Cardano rulez", and he would have none of it. He decides he will intercept this sale.
12. Gonzo scrounges up 600 RMRK and buys the slot from Charlie. Charlie now gets 550, earning 50 on top, and gets a refund of his prepaid tax of another 50. Gonzo has now prepaid 60 RMRK in tax and is poised to become the new owner when a new period starts.
13. A new period starts and Gonzo writes "Avalance rulez". He knows he wants to keep the slot for at least 2 weeks, so 1 day into his ownership, he prepays another 10% tax to keep the slot: 60 RMRK. Meanwhile, the previously escrowed 60 RMRK for his initial tax has now been sent to the contract owner.
14. Almost 2 weeks elapse, and he got zero traction on his message because no one uses Avalanche. He decides to let the slot expire, and does not pay the next Q's tax.
15. On next Q, owner immediately reverts back to contract issuer/owner, price resets to 100, and is immediately put up for sale. The contract issuer can now use this opportunity to modify the params if they wish.