blockchainsolanasolana-web3jssolana-clisolana-transaction-instruction

Solana. Not matched transfer amount and target account balance change


I sent transaction transferring 3000 lamports, but target account balance was increased for 2954 lamports. Link to transaction: https://explorer.solana.com/tx/DyQGm27Qpwm6eU8S7DsQunR3bjVvVUEPPFUYCkd5w2kUh98CVbQmx7Qec2MP4JWoMjCfdgLjY5zypRp9tjPWMKu?cluster=devnet

Why did it happen? How can I predict the exact amount recipient will receive?


Solution

  • Because of the small amount of SOL in the recipient account, it was charged rent for the epoch. This is only charged once per epoch, so subsequent transactions will not incur the additional cost.

    If the account were above the rent-exempt amount, then the full transfer will always go through, as it happened with every other transaction referencing this account. You can check the per-epoch rent amount and rent-exemption for a 0-byte account using solana rent:

    $ solana rent 0
    Rent per byte-year: 0.00000348 SOL
    Rent per epoch: 0.000002439 SOL
    Rent-exempt minimum: 0.00089088 SOL
    

    Predicting the exact amount is very tricky because it's based on when a rent-paying account is visited over the course of an epoch.

    Also, rent-paying accounts will soon be prohibited, so in the future, that transfer will not be allowed.

    More information in the docs at https://docs.solana.com/implemented-proposals/rent