How to run ToEarnFun App
Getting started
Although ToEarnFun is developed using flutter, currently we only implement Bluetooth connection adaptation for Android models. So we only released the APK installation file for Android, you need an Android phone to install it.
Build and install App
Install from APK
Download this 1.0.0-alpha and install it on your Android Mobile Phone.
Install from source code
Clone the latest source code from github.
git clone https://github.com/polketio/toearnfun_flutter_app.gitRun App on local node(Option)
Modify the following code segment of the toearnfun_flutter_app project.
To configure the necessary data for the local node, refer to here.
  //file: toearnfun_flutter_app/lib/plugin.dart
  
  ......
  
  @override
  List<NetworkParams> get nodeList {
    return [
      {
        'name': 'Polket Testnet',
        'ss58': 42,
        'endpoint': 'ws://10.0.2.2:9944', // change the `endpoint` to the url of the local node  
      },
    ].map((e) => NetworkParams.fromJson(e)).toList();
  }
  
  ......Open Android Studio, and open Android Emulator or connect Android Mobile Phone.
# Run ToEarnFun App on Polket testnet
flutter run lib/main_dev.dartBuild APK
flutter build apk --split-per-abiInstall APK
flutter installHow to test
Configure the local node environment(Option)
Open the Polkadot Explorer in a browser and connect to the local node.
In currencies module create an asset FUN for training incentives. 

In events, we see that the AssetId starts at 1.

In vfe module createVfeBrand, fill in the content as shown below.
The same as Assets, the BrandIdstarts at 1.

We use sudo key to set AssetId 1 as the incentive token.

Although we haven't registered a producer yet, the BrandId 1 owner can pre-approve ProducerId 1 to mint 10000 items of VFE.

In the App, we will use a demo account 5C4vzxJwrWbds1wdV5YmMEyeifXhJbFVPQSfzbr371aTLsLp for testing.
So we transfer a little test coins to it for transaction fees.

Import demo account
Click
Import walletbutton.We have filled in a demo
mnemonicfor testing by default. Just clickContinuebutton.Setup the wallet
nameandpassword.



Register and bind device
After the account is created, we will enter the Home page. Then click the Image button, select the Simulated Jump Rope  item to bind device.
In fact, we have already produced a real smart jump rope that can be connected. Due to time constraints, we first provide a simulator for testing.


Follow the steps and select the Simulated device to connect.


Click
Registerbutton, if current account isn't producer, the program first registers the account as aproducer. Then clickRegisterbutton again to register this device on chain.Click
Bindbutton to activate this device on chain.After the binding is successful, you will return
Homepage and get a newVirtual Fitness Equipment(VFE).Click
STATUSlabel,disconnectedwill change toconnected.


Generate simulated training report
Since there is no real equipment, we produce simulated training reports.
In
Homepage ClickMy Traininglabel, enterTraining Reportpage.Click
AppBar right button, the app will generate a simulated training report. Select this report, and click>image button, enter detail page.


Upload training reports and earn FUN rewards
New training reports are available within a 1-day deadline. Click
Report Nowbutton to upload training report on chain.After the runtime verification training report is valid,
FUNrewards will be issued to users. Based on the reported training volume, the user's daily available energy will be consumed.


View user daily training and VFE details
In
Homepage, we can see the user's daily training chart. The user's daily energy will be restored by 25% each period. The user's daily earning cap resets every 24 hours.Click
VFEimage, we can enterVFE Detailpage, see more information aboutVFE.
Sport Type
The system will support 3 sports types: JumpRope, Running, Riding. Currently under development is JumpRope.
VFE Rarity
VFE currently has 4 rarities, and the attribute values of different rarities are different.
Common.
Elite.
Rare.
Epic.
Initial attribute points
The ability of VFE consists of four attributes: Efficiency, Skill, Luck, and Durability, and the range of initial points varies according to the rarity.
Common
2
8
Elite
6
12
Rare
10
18
Epic
20
30


Battery charge
After each successful upload training report, not only the user's energy is consumed, but also the battery of the VFE is consumed.
In the
VFE Detailpage, click theChargebutton at the bottom.In the
dialog view, you can slide theslider bar, select the amount you want to charge, and finally click theconfirmbutton to payFUNas the charging cost.


Level up
To get more FUN, in addition to training every day, you can also level up VFE to improve each training to get more FUN.
In the
VFE Detailpage, click theLevel upbutton at the bottom.In the
dialog view, you can level upVFEby paying enoughFUN.


Increase VFE ability
New points can be added after VFE completes the level up.
In the
VFE Detailpage, click the+ Pointbutton at theAttributes.In the
Add Pointspage You can freely add the available points to each attribute.


Transfer VFE
When you fully charge the VFE and unbind the device, you can transfer money to other users.
In the
VFE Detailpage, first you should unbind theVFE, click theUnbindbutton at the bottom.After the VFE is unbound, you can click the
Transferbutton at the bottom.In the
Send VFEpage, If we want to transferVFEto Alice, just copy Alice's address5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQYto theTextField.(In theAndroid Emulator, long pressTextField, thenPastethe address into it.)Finally, after you check that the address is correct, click
Sendbutton to complete the transfer.




In the explorer, you will find the Transfer event appears. Next, you will use Alice to place an order on the marketplace.

Marketplace
ToEarnFun provides an on-chain VFE marketplace. First, we use Alice to submit an order in the explorer, then we also submit an order in the App, and finally purchase Alice's order in the App.
Make order in Polkadot Explorer
Open the Polkadot Explorer in a browser, go to Developer->Extrinsics. In vfeOrder module submitOrder(assetId, price, deadline, items), fill in the content as shown below. We completed submitting an order with Alice.

Take order in App
In App, the bottom toolbar's last tab is
marketplace. Alice's order appears here.You can buy it now by clicking the
Buybutton on the order item. You can also click on the order to view theVFEdetails.


Make order in App
After the VFE is unbinded, you can sell it to VFE marketplace.
In the
VFE Detailpage, if theVFEis unbond, you can click theSellbutton at the bottom.Place a price, click
Maker Order, and you can sell it to the marketplace.


Cancel Order
You can click
My Saleto view your orders on the marketplace.You can click the
cancelbutton to delete the unblied order.

User wallet
In Home page or VFE Detail page, Click Appbar right button, can enter Wallet page. We can see all assets of user on Polket chain.
The Polket chain is developed based on substrate, and these assets can be circulated to the polkadot ecosystem in the future.

Buyback plan
FUN is not only used in VFE's gameplay, but also can be used to get other assets in the buyback plan.
Create buyback plan
Open the Polkadot Explorer in a browser, go to Developer->Extrinsics. In buyback module createPlan(sellAssetId, buyAssetId, minSell, buybackAmount, sellerLimit, start, period, mode), fill in the content as shown below. We use the Alice account to create a buyback plan.

sellAssetId is the asset used by user will sell to plan. Value 1 is
FUN.buyAssetId is the asset used by the creator for buyback
sellAssetId. Value 0 isPNT.minSell is the limitation of the minimum selling of sellAssetId.
buybackAmount is the total number of buyback plan. Please ensure that the account has sufficient balance available.
sellerLimit is used to limit the number of participants.
start is the block number of the buyback plan when starts. When the plan status is
Inprogress, the user can participate.period is after how many blocks the buyback plan will end.
mode is sell asset will be handle after buyback plan completed.
Buyback plan in App
In the App, you can see the buyback plan just created, click View button to view the plan detail.


Participate in the buyback plan
On the detailed page, you can lock in
FUNto the plan, and then wait for the plan to end.After the plan completed, the plan will give you a reward for another asset according to the final buyback price.


Last updated