Shrekulka / solana-webwallet

1 stars 1 forks source link

It is not possible to send tokens to a wallet with balance = 0.0 #13

Closed o5b closed 5 months ago

o5b commented 5 months ago

When sent tokens to a wallet with balance = 0.0, the transaction does not go through and the following message is returned:

Traceback (most recent call last): File "/home/oleg/projects/bot_solana/bot_v2/solana-webwallet/external_services/solana/solana.py", line 181, in transfer_token response = client.send_transaction(txn, sender_keypair) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oleg/projects/bot_solana/bot_v2/solana-webwallet/env/lib/python3.12/site-packages/solana/rpc/api.py", line 1067, in send_transaction txn_resp = self.send_raw_transaction(txn.serialize(), opts=opts_to_use) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oleg/projects/bot_solana/bot_v2/solana-webwallet/env/lib/python3.12/site-packages/solana/rpc/api.py", line 992, in send_raw_transaction resp = self._provider.make_request(body, SendTransactionResp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oleg/projects/bot_solana/bot_v2/solana-webwallet/env/lib/python3.12/site-packages/solana/exceptions.py", line 43, in argument_decorator return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/oleg/projects/bot_solana/bot_v2/solana-webwallet/env/lib/python3.12/site-packages/solana/rpc/providers/http.py", line 49, in make_request return _parse_raw(raw, parser=parser) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/oleg/projects/bot_solana/bot_v2/solana-webwallet/env/lib/python3.12/site-packages/solana/rpc/providers/core.py", line 97, in _parse_raw raise RPCException(parsed) solana.rpc.core.RPCException: SendTransactionPreflightFailureMessage { message: "Transaction simulation failed: Transaction results in an account (1) with insufficient funds for rent", data: RpcSimulateTransactionResult(RpcSimulateTransactionResult { err: Some(InsufficientFundsForRent { account_index: 1 }), logs: Some(["Program 11111111111111111111111111111111 invoke [1]", "Program 11111111111111111111111111111111 success"]), accounts: None, units_consumed: Some(150), return_data: None, inner_instructions: None }) }

o5b commented 5 months ago

It's not a mistake. Solana accounts require a minimum amount of SOL in order to exists on the blockchain, this is called rent-exempt account. Currently, on mainnet, this amount is around 0.002 SOL (20000000 lamports)

https://solana.com/docs/core/rent#rent-exempt https://solana.com/docs/core/accounts#rent https://ncwallet.net/ru/news/solana-rent/