Back
+10 XP
6/12
Challenge: Build a Transfer Function
Create a function that builds a SOL transfer transaction. The function should take a sender public key, recipient public key, and amount in SOL, then return the transaction object ready to be signed.
Requirements
- Accept sender (PublicKey), recipient (PublicKey), and amount (number, in SOL)
- Convert SOL amount to lamports
- Create and return a Transaction with a SystemProgram.transfer instruction
Test Cases
Should return a Transaction object
Input:
sender, recipient, 1.0Expected: result instanceof TransactionShould contain exactly one instruction
Input:
sender, recipient, 1.0Expected: result.instructions.length === 1