Skip to content

Contract overview

Vasily Styagov edited this page Sep 2, 2022 · 3 revisions

SWEAT the TOKEN

Smart contract that implements the NEP-141 fungible token standard, as well as NEP-148 metadata and NEP-297 events standard extensions.

Concepts

Token account - an account with the contract code deployed to it.

Oracle account - an account in an allow-list to provide steps activity data to the token (call the record_batch contract method).

Oracle - a service that provides verified physical activity data. Has access to Oracle account keys.

Formula - a function that specifies conversion rate of physical activity data to fungible token.

Overview

Main purpose of the contract is converting users steps activity data (provided by an Oracle) into fungible tokens:

  • Oracle (more specifically, Sweatcoin) periodically records users' verified steps data to the token (via calling the record_batch method)
  • The steps data is converted into fungible tokens via using the formula, and minted to the active user's account, minus 5% commission that is minted to Oracle account for it's verification services.
  • The conversion rate (formula) is not static and depends on total steps that have been accumulated in the contract.

Methods

Standard methods

Contract implements standard methods of NEP-141 (ft_transfer, ft_transfer_call, view methods ft_total_supply, ft_balance_of), storage staking methods (storage_deposit, storage_withdraw, storage_unregister, view methods storage_balance_of and storage_balance_bounds), and NEP-148 metadata view method ft_metadata. All of these behave according to the standards.

Custom methods

add_oracle and remove_oracle

Adds or removes and account to Oracle allow-list.

Can only be called by the Token Account.

get_oracles

View method that lists current Oracle Accounts

tge_mint

Method that is used at the TGE (token generation event) to mint initial token allocations ("airdrop" as promoted on the Sweatcoin App).

Mints the specified amount of tokens to the provided account.

Emits a NEP-297 ft_mint event.

Will be removed from the contract after the TGE is conducted.

tge_mint_batch

Same as tge_mint, but accepts a list of mints. Emits a NEP-297 ft_mint event per list element.

Used to batch mints together as a performance improvement.

Will be removed from the contract after the TGE is conducted.

burn

Irreversably removes a specified amount of the caller's tokens from circulation.

Emits a NEP-297 ft_burn event.

get_steps_since_tge

View method that returns total amount of steps accumulated in the contract, used by the Formula.

record_batch

Method that accepts a list of accounts and their steps from the Oracle.

Can only be called by an Oracle.

Mints tokens to the accounts according to Formula, minus 5% commission that is minted to the Oracle account. Adds all the converted steps to the total steps counter.

Emits an NEP-297 ft_mint event per element in the argument list + a single event for total commission to Oracle.

Batching is a performance optimisation.

formula

Calculates the amount of tokens to be minted into existance with given parameters.