If you already have rustup
installed, you can ensure that the correct version of the compiler and the NEAR CLI is installed as well:
make install
To learn how to build the project, deploy it, and run tests run the following command:
make help
First build the contract using provided make
command:
make build
Then deploy and initialize it. Rename dev.env.example
to dev.env
and define variable values there. To deploy the contract to dev-account on Testnet use the following command:
make deploy
Once finished, check the neardev/dev-account
file to find the address in which the contract was deployed:
cat ./neardev/dev-account
# e.g. dev-1659899566943-21539992274727
If you build your contract on two different machines, it's highly likely that you'll obtain two binaries that are similar but not exactly identical. Your build outcome can be influenced by various factors in your build environment, such as the locale, timezone, build path, and numerous other variables.
To obtain an identical build artifact on any machine, matching the one deployed on NEAR, you can build it using Docker:
make build-in-docker
The claim feature is an extension of the Sweat Wallet application and aims to safely store the $SWEAT minted for a given users based on their steps provided by the Sweatcoin Oracle and converted to $SWEAT as per the token's minting curve.
Prior to this "claim" feature, $SWEAT accrued from steps was calculated several times per day as determined by the Sweatcoin Oracle and $SWEAT was minted accordingly by the token.sweat
contract and transferred to the given user's wallet address. The goal of the "claim" feature is to given the user more control over their $SWEAT earned from walking. This is accomplished by diverting minted $SWEAT to a new contract where it will accrue until a user claims it.
The contract furthermore caters for edge cases in user behaviour which current places the Sweat economy at risk. E.g. If a user churns and disbands the project then there should be a mechanism to recover $SWEAT that was minted to a user's address but abandoned by the user. Currently this is impossible as Sweat Wallet is a self-custody thereby rendering complete control of funds to the user. Having a contract where minted $SWEAT accrues provides a degree of separation in terms of ownerships rights /control of minted $SWEAT. Sweat Wallet may therefore impose a condition that $SWEAT which is not claimed after a set amount of time may be burned from the claim contract. This will not only create a healthier economy (supply vs demand) but furthermore provide a method for maintaining an efficient contract size.
The following users provide some context as to how users will interact with the contract from the Sweat Wallet application.
- As a server I want to impose a 48 hour count down time (offchain) which prevents the "Claim" button from being active. After the 48 hours have matured, the Claim button should be shown as active such that a user may interact with it.
- As a server I want to inform a user based on internally stored thresholds, when $SWEAT that has accrued has not been claimed after x days and/or y amount. This may be accomplished by push notifications in-app.
- As a server I want to be alerted when a user has not claimed for 30 days and inform the user that the
burn
method will be invoked in the contract for the server to request to burn accrued $SWEAT that has not been claimed for more than 30 days. - As a server I want to regularly monitor contract storage size and evaluate Sweatcoin Oracle data to optimize data entries into the claim contract.
- As a server I want to limit contract interaction by requiring an active Sweat Wallet UUID that matches a valid keypair to prevent access to the contracts function from independent users (users not using an active Sweat Wallet session)
- As a user I want to view my accrued $SWEAT in-app
- As a user I want to see a progress bar showing how much time is remaining (of the 48 hours) before I can access the Claim button.
- As a user I want to view claimed $SWEAT in my Available Balance as soon as a successful claim has been initiated.
- As a user, after claiming, I want to see the countdown timer and associated progress bar reset.
- As a user I want to be notified when any $SWEAT get burned from my associated associated address in the claim contract.
- As a user I want to see the gas fee displayed before interacting in any way with the claim contract.
- As a user I want to receive logical error messages when a contract interaction fails e.g. insufficient NEAR or $SWEAT to cover gas fees, etc. or any reason that causes the contract to panic.
- As a user I want to receive notifications before an method is called in the claim contract by the server that affects my unclaimed balance in the smart contract (offchain functionality)