Assignment 1: Taxed Token Program
The goal of this first assignment is to familiarize with the token program. In this assignment, you'll extend the token program we developed earlier by implementing a transaction tax feature. This feature will allow the admin to receive a percentage of the transfer as tax.
Learning Objectives
By completing this assignment, you will:
Apply your knowledge of Leo programming for state management
Implement more complex token interactions
Understand how to handle percentage-based calculations
Tasks
Implement tax collection for the
transfer_private
function. The tax should be added to the private balance of theADMIN
address.Implement tax collection for the
transfer_public
function. The tax should be added to the public balance of theADMIN
address.Implement tax collection for the
transfer_public_to_private
function. The tax should be added to the public balance of theADMIN
address.Implement tax collection for the
transfer_private_to_public
function. The tax should be added to the public balance of theADMIN
address.
The tax should be hard coded as a constant: TAX
. It should be represented as a u16 representing the per ten thousand value of the amount sent. For instance if the tax u16
is set as 15, the tax should be the floor of 0.15% of the amount per transfer. The tax should be deducted from the amount of token spent, and credited to the balance of ADMIN
address, according to the specifiactions above.
Last updated