code challenge20 min
Setting Up Your Environment
Setting Up Your Development Environment
Before we start building, let's set up the tools you'll need for Solana development.
Prerequisites
You should have the following installed:
Make sure you're on Solana CLI v1.18 or later. Earlier versions have known compatibility issues with the latest Anchor releases.
Challenge
Write a TypeScript function that connects to Solana devnet and fetches the current slot number.
1Import Connection from @solana/web3.js
2Connect to the devnet cluster
3Fetch and return the current slot number
Hints
0/3 revealed🔒 Hint 2 — reveal previous hints first
🔒 Hint 3 — reveal previous hints first
Solution
⚠️ Try solving it yourself first!
solution.ts
Test Cases
Creates Connection to devnetConnection object created
Calls getSlot()Returns a number
Returns valid slot numberslot > 0