The Tech

A brief rundown of the tech involved in building The Commissary

The Commissary is a project marketplace for the Inmates project. The building of this marketplace presented us a unique challenge because of their specific taxation system that is intrinsic to their project economy.

The Inmates team requires every item sold on The Commissary to contribute a 15% tax towards the project treasury.

From the blockchain tech point of view, this is uniquely interesting. The taxation system is interesting, in that holders of NFTs in their Guards collection enjoy tax exemption in The Commissary. As developers, we need to think about how best to do this to achieve the greatest benefit for all parties involved, including the Inmates team, the buyer, seller, and us.

There are several options for enforcing this tax and each comes with its unique technical challenges and pitfalls.

Solution 1 - Tax paid at the point of listing

To do this, we will need to craft the listing transaction such that the tax that is due is paid at the point of listing. This will be an upfront cost to the seller which may deter usage, and also makes it difficult to refund the tax on delisting. Users with no $smokes will also not be able to list.

A possible option to support delisting is to pay the tax to a custodial wallet which we control so that we can fully code for refund transactions at the point of delisting. However this opens up an additional attack vector and possible liabilities which put us as a contractor in a vulnerable position.

Another possible option to support tax refunds when tax is paid at the point of listing is to use a multi-sig wallet or a smart contract to hold this tax. This reduces the risks imposed on us but still makes the system highly unattractive for sellers.

Solution 2 - Tax paid at the point of buying

To achieve this, the buyer simply pays the listing price in 2 UTxOs in the same transaction. There is no loss of the buyer and no upfront cost for the seller, and the tax automatically goes into the project treasury upon conclusion of the sale. This is the solution we chose to offer to the Inmates team.

This sounds like an ideal solution, but on the technical front there are several major challenges. The main challenge is the determination of the seller's tax exemption status both at the point of listing and at the point of sale.

If we simply allowed the tax amount to be entered as 0 into the datum of the listing UTxO to denote tax exemption, then because of the decentralised nature of smart contracts, anyone can write such a transaction and evade tax even without holding a Guard NFT.

Therefore the smart contract we wrote for Inmates has two specific validations to confirm tax exemption status.

  • When listing - the smart contract validates that a Guard NFT has been included in the inputs. We build these transactions such that a Guard NFT is taken from the seller's wallet and paid back to the seller in the same transaction. As all the inputs of a transaction need to be signed for, the very fact that the seller is able to correctly sign for this listing transaction proves that, at the point of listing, the seller does indeed have spending rights over at least a Guard NFT. If this condition is not met, the smart contract will reject a transaction that specifies a 0 value for tax, and will only validate if the tax value is set to exactly 15% of the listing value.

  • When buying - the smart contract validates that a reference input UTxO has been included in the transaction and that it contains a Guard NFT and that the UTxO belongs to a wallet address with the same staking key as the seller. Because reference inputs do not need to be signed for, this buying transaction only requires the buyer's signature and causes no additional burden on the seller. Using stake key to identify the UTxO supports sellers using multi-address wallets, and also excludes scenarios where the seller has loaned out their Guard NFT on any lending platform. If this condition is not met, the smart contract will not allow a 0 tax sale to proceed, but will mandate that the 15% tax be paid.

By doing so, we are able to build the marketplace smart contract that enforces the specific taxation rules decided upon by the project and strictly enforce it with safeguards against tax evasion.

Last updated