Skip to content

Convert lamports to SOL [Solana] #359

Answered by Kremed
Kremed asked this question in Q&A
Discussion options

You must be logged in to vote

I found the wallet repository contains how to perform this process, someone may benefit from this in the future

private async Task GetAccountBalance()
{
    var balance = await _rpcClient.GetBalanceAsync(CurrentWallet.Address, Solnet.Rpc.Types.Commitment.Confirmed);

    if (balance.WasRequestSuccessfullyHandled)
    {
        CurrentNativeBalance = balance.Result.Value;
        CurrentBalance = SolHelper.ConvertToSol(balance.Result.Value);
    }
}
public static decimal ConvertToSol(ulong lamports)
  {
      return decimal.Round((decimal)lamports / 1000000000m, 9);
  }

I'm sorry for the many questions and inconveniences,

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kremed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant