0

In a custom pallet, I have been using set_lock() for a staking purpose. But once the lock is done I thought the free_balance() will reduce in the account's balance but it stays the same and only the below got updated.

{
  nonce: 2
  consumers: 1
  providers: 1
  sufficients: 0
  data: {
    free: 999,999,973,799,998,827,689,554 // This was same before and after set_lock as well
    reserved: 0
    miscFrozen: 250,000,000,000,000,000,000,000
    feeFrozen: 250,000,000,000,000,000,000,000
  }
}

1 Answer 1

1

These two parts overlap: available = free - lock.

The variable lock is simply a number and does not represent the amount of a token. It is possible to set a lock of 100 units on an account that only has 1 unit.

Consider using the function ensure_can_withdraw.


By the way, it is recommended to switch to using freeze instead of lock after implementing this change: https://github.com/paritytech/substrate/pull/12951.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.