MetaMask / MetaMask/metamask-mobile

Token balance check to not happen in app

Open
#1,652 0 comments 0 reactions 0 assignees View on GitHub
community
Dominant language
TypeScript
Stars
3k
Forks
1.7k
Avg merge
1d 14h
Merged PRs (30d)
669

Description

**Describe the usability problem**
_A clear and concise description of the specific usability issue_

Currently, it appears that the mobile app checks the token balance before allowing to send and if it is too low, the user can not send tokens. Whilst this seems a good practice, it does not allow for some use cases in which the smart contract manipulates the balance (increases the balance) before executing the transaction.

E.g. The smart contract for the Value Instrument token concept allows for a regular payout given to users (a "UBI token"). In simplified terms, this results in an increasing token balance over time.

In order to save on gas cost, the on-chain balance of the user is updated only when a transaction occurs, calculating the amount to be added based on the time passed since the previous transaction. This means that the actual spendable balance may (likely) be higher than the stored balance.

Disabling the send on a seemingly to low balance, renders the MetaMask app unusable for networks using such token, and any other smart contract with comparable behaviour.

**Screenshots**
_If applicable, add screenshots or links to help explain the issue_

Example of above token concept:

Gross Spendable: 295
Net Spendable: 197
On Chain Balance: 53

In the above example some time has passed since the last transaction occurred in which the user depleted their account to 53 tokens. Meanwhile the user is entitled to new tokens and the the actual spendable balance, according to the timeframe is 295 (gross) or 197 (net, considering an exemplary fee of 50% per transaction).

**Expected behavior**
_If possible, a clear and concise description / resolution of what you expected to happen_

allow sending of tokens without checking token balance in advance and let smart contract return an error, if balance is too low. Do not limit the creativity of smart contract development by enforcing a balance check, as stored balance may not be the same as spendable balance.

(developers shall be encouraged to build in checks into the UI instead)

------------------------------------------------------------------------------------------------------
_filled out after submission_

**User impact | Usage frequency | Feasibility scores**
_How important is this to the user, what the user wants to accomplish | Daily, weekly, monthly | Small, medium, large_

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named in the issue. Start by tracing the mobile token-send flow and its pre-send token-balance check, then verify that sending proceeds for tokens whose spendable balance can be updated by a smart contract and that insufficient balances still surface the contract error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
blockchain, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.