1

I generate a new key pair by running:

solana-keygen new --force

I print out the address:

solana address
2EHCPkQHcjiBUgWT6zpcHmLPbW2r6wKtb9RjYnoBwFb7

Now I tried to get the account details associated with the key pair and it fails:

solana account 2EHCPkQHcjiBUgWT6zpcHmLPbW2r6wKtb9RjYnoBwFb7
Error: AccountNotFound: pubkey=2EHCPkQHcjiBUgWT6zpcHmLPbW2r6wKtb9RjYnoBwFb7

But then I request some airdrop to the keypair:

solana airdrop 20 2EHCPkQHcjiBUgWT6zpcHmLPbW2r6wKtb9RjYnoBwFb7
Requesting airdrop of 20 SOL

Signature: 5mFtSdv5FznG9SE6yfJt3kDRAssdy7nQJRLdVTvMBni8nUPJDG8BFcjT1i7CLAWeqjfatvSdDjUUbPxhzberzjgn

20 SOL

After which, when I run solana account again, the command works:

solana account 2EHCPkQHcjiBUgWT6zpcHmLPbW2r6wKtb9RjYnoBwFb7

Public Key: 2EHCPkQHcjiBUgWT6zpcHmLPbW2r6wKtb9RjYnoBwFb7
Balance: 20 SOL
Owner: 11111111111111111111111111111111
Executable: false
Rent Epoch: 0

Question is, what happens behind the scene with requesting the airdrop that only makes it possible to run the solana account command after?

Also is it possible to create a keypair and its associated account via the command line without having to request an airdrop?

1 Answer 1

3

When you run solana-keygen new that's only creating a keypair locally on your system.

When you run solana address it reads that local keypair and displays its address

In both cases this is all local and there's no interaction with the Solana network.

When you run solana account ... it goes to the network and requests data stored for that public key on the network. Since to this point you've never told the network about this account, it doesn't find anything.

When you run solana airdrop ... it sends SOL to the public key. At that point the network has to create the account to store a SOL balance for that public key and retain it on-chain.

So the next time you run solana account ... there's on-chain data that it can return to you.

Also is it possible to create a keypair and its associated account via the command line without having to request an airdrop?

AFAIK the only way is to send some SOL to the account. If you do this then you need to send enough SOL to make the account rent-exempt. That means it'll have enough SOL to have its data stored permanently on the network.

You can send SOL to any public key using the CLI: solana transfer 8njcr6FbteVdXoGXZrZUKeicLBLBsRtjwyzqzfE28ETx 0.001 --allow-unfunded-recipient

You need the --allow-unfunded-recipient flag to allow the transaction to happen even though the public key doesn't currently have an account stored on the network.

In practice I found that the above example of transferring 0.001 worked, but 0.0001 didn't. It said that this would leave an account with a balance smaller than the rent-exempt minimum. So the minimum you need to fund the account with to make a SOL account rent-exempt is somewhere between those two values.

You'll also find something similar with airdrop:

$ solana airdrop 0.0001 ACQkTjp8LRGngKa4qCNmoWdgNeitPq14KjWHd4AvZtXa
Requesting airdrop of 0.0001 SOL
Error: Transaction results in an account (1) without insufficient funds for rent

In short, the network will not store a SOL account with less than ~0.001 SOL. Which means you can't have a SOL account with 0 SOL stored on the network.

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.