Skip to main content
Superteam Brasil
Back
+10 XP
4/12

Challenge: Generate a Keypair

Now it is your turn! Write a function that generates a new Solana keypair and returns an object with the public key (as a base58 string) and a boolean indicating whether the keypair is valid.

Requirements

  • Import Keypair from @solana/web3.js
  • Generate a new keypair
  • Return an object with publicKey (base58 string) and isValid (boolean)
  • A keypair is valid if the public key is on the ed25519 curve

Test Cases

Should return an object with publicKey and isValid
Input: Expected: typeof result === 'object' && result.publicKey && result.isValid !== undefined
Public key should be a valid base58 string
Input: Expected: typeof result.publicKey === 'string' && result.publicKey.length >= 32
isValid should be true
Input: Expected: result.isValid === true

Discussion