AlexD10S / substrate-betting

Substrate decentralized betting pallet for learning purposes
11 stars 4 forks source link

Runtime constant - Minimum amount for betting #3

Open AlexD10S opened 1 year ago

AlexD10S commented 1 year ago

There is an issue is with the Existential Deposit when transferring the pot.

For example the pot has 10 UNITS, and has to distribute 9 UNITS to A and 1 to B. And the Existential Deposit is 2 UNITS.

Currently for the transfer we are using the flag AllowDeath which send the funds anyway the balance goes below the Existential Deposit.

T::Currency::transfer(
    &T::account_id(),
    &winner,
    amount_won,
    AllowDeath,
)?;

In that scenario, if is trying to send the fund to player A first (9 UNITS) it will success but the account will be reaped and the second will fail.

One solution to this issue can be adding a constant with minimum amount for betting and requiring it to be no less than existential deposit

AlexD10S commented 1 year ago

Issue in StackExchange: https://substrate.stackexchange.com/questions/6436/fund-a-pallet-accountid