Back to Course
6/8
75 XP
code challenge25 min

Build Your First Transaction

Build Your First Transaction

Time to put theory into practice! In this challenge, you'll build a SOL transfer transaction from scratch.

Your Task

Write a function that creates a transaction to transfer SOL from one wallet to another.

Use SystemProgram.transfer() to create the transfer instruction. It takes fromPubkey, toPubkey, and lamports as parameters.

Challenge

Create a function that builds a SOL transfer transaction. The function should take a sender, recipient, and amount in SOL.

1Create a new Transaction object
2Add a SystemProgram.transfer instruction
3Convert SOL to lamports (1 SOL = 1,000,000,000 lamports)
4Return the unsigned transaction

Hints

0/4 revealed
🔒 Hint 2 — reveal previous hints first
🔒 Hint 3 — reveal previous hints first
🔒 Hint 4 — reveal previous hints first

Solution

⚠️ Try solving it yourself first!