1

I see the following documentation on: https://docs.solana.com/cli/transfer-tokens#send-tokens

solana transfer --from <KEYPAIR> <RECIPIENT_ACCOUNT_ADDRESS> <AMOUNT> --fee-payer <KEYPAIR>

But can someone give me a real life example of how this output should be with real addresses and keypairs?

I'm a bit confused with KEYPAIR, is this a file or the private key? Can I just pass in a base58 private key? What if I only have the 24 word seed of a wallet? Can I pass in the seed into it?

1 Answer 1

1

The KEYPAIR is a file containing a Solana keypair, it'll be a JSON file containing an array of 64 bytes (numbers 0-255).

You generate it using solana-keygen new. That'll create it at ~/.config/solana/id.json

Here's a complete example, transferring from a keypair I've created at temp.json to the public key 3GWzdwDqphjz5zi4s8fpeNi5YXKqFSgcMq86BRnS3dnS:

$ solana transfer --from ~/.config/solana/temp.json 3GWzdwDqphjz5zi4s8fpeNi5YXKqFSgcMq86BRnS3dnS 0.1 --allow-unfunded-recipient --fee-payer ~/.config/solana/temp.json

Signature: 5UDry1YScxWRtcjCHxnyGcRxS2DxHxhFnmnHYMr77TVrJWieHZmCy25pvpMfH39xLBQbnjMsXqDJZKfaptQWv7VS

$ solana balance 3GWzdwDqphjz5zi4s8fpeNi5YXKqFSgcMq86BRnS3dnS
0.1 SOL
4
  • but what if i only have the base58 private key string? How do I send with that? Also what do you do with the signature? Commented Aug 9, 2022 at 13:46
  • You can write a small script that takes the private key and outputs the keypair file, see my answer here: solana.stackexchange.com/a/1044/289. Then you can use whichever file you output that to where I have ~/.config/solana/temp.json (as KEYPAIR). The signature just identifies the transaction and lets you view it in future, you can see my one for this answer on explorer here: explorer.solana.com/tx/…
    – Callum M
    Commented Aug 9, 2022 at 14:02
  • is there a way to just skip the creation of the keypair .json file and just use the base58 string instead? I have all the private keys stored in a database, and that means every time I make a transaction this script will be creating a .json file to just make a send transaction? Commented Aug 9, 2022 at 14:06
  • Not that I'm aware of if you want to use the CLI, but take that with a grain of salt because I'm not an expert there. In your case though I'd just write a NodeJS script because there you can create a Keypair object in @solana/web3.js directly from the base58 key and then use that to sign transactions. Plus if you're reading from a DB that's probably going to make much more sense in a NodeJS script than something in the CLI too. See the TS code example here: solanacookbook.com/references/…
    – Callum M
    Commented Aug 9, 2022 at 14:08

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.