Building a frontend?If your application lets users enter a recipient account, follow the Validating Recipient Accounts guide to catch typos and non-existent accounts before broadcasting a transaction.
- Improper key management
- Refunding deleted accounts
- Failed function calls in batches
Improper key management
Improper key management may lead to token loss. Mitigating such scenarios may be done by issuing backup keys allowing for recovery of accounts whose keys have been lost or deleted.Loss of FullAccess key
A user may lose their private key of a FullAccess key pair for an account with no other keys.
No one will be able to recover the funds. Funds will remain locked in the account forever.
Loss of FunctionCall access key
An account may have its one and only FunctionCall access key deleted.
No one will be able to recover the funds. Funds will remain locked in the account forever.
Refunding deleted accounts
System refunds require an existing receiving account. If a refund cannot be delivered because the account no longer exists, its amount is burned.Deleting account with non-existent beneficiary
Deleting an account and paying its beneficiary happen in separate receipts:- Account
Ais deleted with accountBas its beneficiary. - The runtime sends
A’s remaining balance toBin a system payout receipt. - If
Bdoes not exist when that receipt executes, the payout fails and its amount is burned. The deletion ofAis not rolled back.
- Send a normal
Transfer, leaving enough NEAR for transaction fees and any required storage balance. - Wait for finalized success and for all outstanding receipts and refunds to complete. If the transfer fails, resolve the failure before deleting the account.
- Verify that the beneficiary exists, then submit a separate
DeleteAccounttransaction to send the remaining account balance, including any dust or released storage balance, to that beneficiary. Check the payout’s finalized outcome as well.
Account deleted before it receives a refund
If an account is explicitly deleted while refunds are outstanding, those refunds can become undeliverable and be burned. Keep the account until all outstanding receipts and refund outcomes have finalized.Failed function calls in batches
If a contract functionf1 calls two (or more) other functions f2 and f3, and at least one of these functions, f2 and f3 fails, then tokens will be refunded from the function that failed, but tokens will be appropriately credited to the function(s) which succeed.
The successful call’s tokens may be considered lost depending on your use case if a single failure in the batch means the whole batch failed.