4

I found this below at this, to send SOL from one wallet to another.

const transferTransaction = new Transaction()
  .add(SystemProgram.transfer({
    fromPubkey: alice.publicKey,
    toPubkey: feePayer.publicKey,
    lamports: lamportsToSend
  }))

What should be the value of lamportsToSend? Please don't link to an online guide cos I read all of them and still don't get it.

2 Answers 2

6

Lamports are like the "satoshi" or "cents" of Solana. The smallest unit of value.

1 USD = 100 cents

1 BTC = 100 million satoshi

1 SOL = 1 billion lamports

https://docs.solana.com/terminology#lamport

2
  • What's the best way to get lamportsToSend value?
    – ratib90486
    Commented Aug 9, 2022 at 0:47
  • If you want to sell X SOL, then multiply X by a billion, and that's how many lamports you want to send. e.g. 0.001 SOL = 1,000,000 lamports.
    – HelmetFace
    Commented Aug 9, 2022 at 1:15
1

Lamports are the smallest unit value in Solana. 1 Solana is 1000000000 lamports (one billion).

As an example, if you want to send 1.2 Sol with @solana/web3.js, the value of lamports in your TransferInstruction would be 1.2 * LAMPORTS_PER_SOL.

LAMPORTS_PER_SOL is a constant that's provided by the web3.js library.

It's also worth noting that for SPL tokens, the amount of Decimals that the SPL token is minted with determines your multiplier. You cannot always multiply by LAMPORTS_PER_SOL for SPL tokens. Rather, the number of zeros in your multiplier should match the decimals of the token.

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.