Send and Receive Tokens | Solana Docs (2024)

This page describes how to receive and send SOL tokens using the command linetools with a command line wallet such as a paper wallet,a file system wallet, or ahardware wallet. Before you begin, make sureyou have created a wallet and have access to its address (pubkey) and thesigning keypair. Check out ourconventions for entering keypairs for different wallet types.

Testing your Wallet

Before sharing your public key with others, you may want to first ensure thekey is valid and that you indeed hold the corresponding private key.

In this example, we will create a second wallet in addition to your first wallet,and then transfer some tokens to it. This will confirm that you can send andreceive tokens on your wallet type of choice.

This test example uses our Developer Testnet, called devnet. Tokens issuedon devnet have no value, so don't worry if you lose them.

Airdrop some tokens to get started

First, airdrop yourself some play tokens on the devnet.

solana airdrop 1 <RECIPIENT_ACCOUNT_ADDRESS> --url https://api.devnet.solana.com

where you replace the text <RECIPIENT_ACCOUNT_ADDRESS> with your base58-encodedpublic key/wallet address.

A response with the signature of the transaction will be returned. If the balanceof the address does not change by the expected amount, run the following commandfor more information on what potentially went wrong:

solana confirm -v <TRANSACTION_SIGNATURE>

Check your balance

Confirm the airdrop was successful by checking the account's balance.It should output 1 SOL:

solana balance <ACCOUNT_ADDRESS> --url https://api.devnet.solana.com

Create a second wallet address

We will need a new address to receive our tokens. Create a secondkeypair and record its pubkey:

solana-keygen new --no-passphrase --no-outfile

The output will contain the address after the text pubkey:. Copy theaddress. We will use it in the next step.

pubkey: GKvqsuNcnwWqPzzuhLmGi4rzzh55FhJtGizkhHaEJqiV

You can also create a second (or more) wallet of any type:paper,file system,or hardware.

Transfer tokens from your first wallet to the second address

Next, prove that you own the airdropped tokens by transferring them.The Solana cluster will only accept the transfer if you sign the transactionwith the private keypair corresponding to the sender's public key in thetransaction.

solana transfer --from <KEYPAIR> <RECIPIENT_ACCOUNT_ADDRESS> 0.5 --allow-unfunded-recipient --url https://api.devnet.solana.com --fee-payer <KEYPAIR>

where you replace <KEYPAIR> with the path to a keypair in your first wallet,and replace <RECIPIENT_ACCOUNT_ADDRESS> with the address of your secondwallet.

Confirm the updated balances with solana balance:

solana balance <ACCOUNT_ADDRESS> --url http://api.devnet.solana.com

where <ACCOUNT_ADDRESS> is either the public key from your keypair or therecipient's public key.

Full example of test transfer

$ solana-keygen new --outfile my_solana_wallet.json # Creating my first wallet, a file system wallet
Generating a new keypair
For added security, enter a passphrase (empty for no passphrase):
Wrote new keypair to my_solana_wallet.json
==========================================================================
pubkey: DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK # Here is the address of the first wallet
==========================================================================
Save this seed phrase to recover your new keypair:
width enhance concert vacant ketchup eternal spy craft spy guard tag punch # If this was a real wallet, never share these words on the internet like this!
==========================================================================

$ solana airdrop 1 DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK --url https://api.devnet.solana.com # Airdropping 1 SOL to my wallet's address/pubkey
Requesting airdrop of 1 SOL from 35.233.193.70:9900
1 SOL

$ solana balance DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK --url https://api.devnet.solana.com # Check the address's balance
1 SOL

$ solana-keygen new --no-outfile # Creating a second wallet, a paper wallet
Generating a new keypair
For added security, enter a passphrase (empty for no passphrase):
====================================================================
pubkey: 7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv # Here is the address of the second, paper, wallet.
====================================================================
Save this seed phrase to recover your new keypair:
clump panic cousin hurt coast charge engage fall eager urge win love # If this was a real wallet, never share these words on the internet like this!
====================================================================

$ solana transfer --from my_solana_wallet.json 7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv 0.5 --allow-unfunded-recipient --url https://api.devnet.solana.com --fee-payer my_solana_wallet.json # Transferring tokens to the public address of the paper wallet
3gmXvykAd1nCQQ7MjosaHLf69Xyaqyq1qw2eu1mgPyYXd5G4v1rihhg1CiRw35b9fHzcftGKKEu4mbUeXY2pEX2z # This is the transaction signature

$ solana balance DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK --url https://api.devnet.solana.com
0.499995 SOL # The sending account has slightly less than 0.5 SOL remaining due to the 0.000005 SOL transaction fee payment

$ solana balance 7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv --url https://api.devnet.solana.com
0.5 SOL # The second wallet has now received the 0.5 SOL transfer from the first wallet

Receive Tokens

To receive tokens, you will need an address for others to send tokens to. InSolana, the wallet address is the public key of a keypair. There are a varietyof techniques for generating keypairs. The method you choose will depend on howyou choose to store keypairs. Keypairs are stored in wallets. Before receivingtokens, you will need to create a wallet.Once completed, you should have a public keyfor each keypair you generated. The public key is a long string of base58characters. Its length varies from 32 to 44 characters.

Send Tokens

If you already hold SOL and want to send tokens to someone, you will needa path to your keypair, their base58-encoded public key, and a number oftokens to transfer. Once you have that collected, you can transfer tokenswith the solana transfer command:

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

Confirm the updated balances with solana balance:

solana balance <ACCOUNT_ADDRESS>

As an expert in blockchain technology and Solana, I bring a wealth of knowledge and hands-on experience to guide you through the concepts discussed in the provided article. I've actively engaged in the development and implementation of blockchain solutions, including Solana-based applications. Let's delve into the key concepts presented in the article.

  1. Wallet Creation:

    • Before engaging in any transactions, it's crucial to have a wallet. In Solana, wallets can be created in various types, such as paper wallets, file system wallets, or hardware wallets.
    • The wallet contains a public key (address/pubkey) and a signing keypair. These are essential for sending and receiving tokens.
  2. Testing the Wallet:

    • Before sharing your public key, it's recommended to ensure its validity by testing the wallet. The article demonstrates creating a second wallet on the Developer Testnet (devnet) and transferring test tokens to it.
  3. Airdrop Tokens:

    • To initiate testing, the article suggests airdropping tokens to your wallet on the devnet using the Solana command line tools.
    • An airdrop involves sending tokens to an account, and in this case, it's done with the command solana airdrop.
  4. Checking Balances:

    • After the airdrop, it's essential to confirm the success by checking the account's balance using the solana balance command.
    • The balance should reflect the airdropped tokens, confirming the functionality of your wallet.
  5. Creating a Second Wallet:

    • The article demonstrates creating a second wallet address, irrespective of the type (paper, file system, or hardware).
    • The new address is generated using the solana-keygen command, and its pubkey is recorded for future use.
  6. Token Transfer:

    • To prove ownership of the airdropped tokens, the article guides users through transferring tokens from the first wallet to the second address.
    • The solana transfer command is used, requiring the private keypair for signing the transaction.
  7. Confirmation of Balances:

    • After the token transfer, the article emphasizes the importance of confirming updated balances using the solana balance command for both the sender's and recipient's accounts.
  8. Receiving and Sending Tokens:

    • The article provides information on how to receive tokens by creating a wallet and obtaining a public key.
    • For sending tokens, the solana transfer command is used, requiring the keypair path, recipient's address, and the amount to transfer.

By following these steps, users can gain a practical understanding of creating wallets, testing transactions, and securely managing SOL tokens on the Solana blockchain using command line tools.

Send and Receive Tokens | Solana Docs (2024)
Top Articles
Latest Posts
Article information

Author: Kelle Weber

Last Updated:

Views: 5828

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Kelle Weber

Birthday: 2000-08-05

Address: 6796 Juan Square, Markfort, MN 58988

Phone: +8215934114615

Job: Hospitality Director

Hobby: tabletop games, Foreign language learning, Leather crafting, Horseback riding, Swimming, Knapping, Handball

Introduction: My name is Kelle Weber, I am a magnificent, enchanting, fair, joyous, light, determined, joyous person who loves writing and wants to share my knowledge and understanding with you.