Ramblings from a Linux, Security, and Web3 Geek
Ramblings from a Linux, Security, and Web3 Geek

Subscribe to Graymans Block

Subscribe to Graymans Block
Share Dialog
Share Dialog


<100 subscribers
<100 subscribers
I have started a bit of a journey to discover the Solana blockchain and ecosystem. This here is a beginner's guide I've created from the knowledge I've learned from using the Solana Command Line Interface (CLI). The Solana CLI is a powerful tool that lets you interact with the Solana blockchain, enabling you to manage wallets, send transactions, and more. This tutorial will walk you through the basics to get you started.
A little warning, use of the Solana CLI and interaction with the Solana blockchain involves risks, including but not limited to loss of funds, security vulnerabilities, and regulatory implications. It is essential to know and understand the regulatory environment of your jurisdiction before engaging in blockchain-related activities.
First, you need to install the Solana CLI on your system. The process is straightforward and varies slightly depending on your operating system.
Open your terminal and run the following command:
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"Windows users should use the Windows Subsystem for Linux (WSL) and then run the same command as macOS and Linux users.
After installing, you can check if it was successful by running:
solana --versionThis command will display the version of Solana CLI installed.
Solana operates on different networks: Mainnet Beta, Testnet, and Devnet. To set your environment to one of these networks, use the config set command:
solana config set --url <network>Replace <network> with the appropriate URL for your desired network:
Mainnet Beta: https://api.mainnet-beta.solana.com
Testnet: https://api.testnet.solana.com
Devnet: https://api.devnet.solana.com
A wallet is essential for holding your SOL tokens and interacting with the Solana blockchain. To create a new wallet:
solana-keygen new --outfile ~/my-solana-wallet.jsonThis command creates a new wallet and saves the keypair to the specified file. Keep this file safe, as it contains your private keys.
To check the balance of your wallet, use:
This command will show the current balance of your SOL tokens.
You can send SOL to another address using the transfer command. Here's how:
solana transfer --from ~/my-solana-wallet.json <RECIPIENT_ADDRESS> <AMOUNT>Replace <RECIPIENT_ADDRESS> with the address of the recipient and <AMOUNT> with the amount of SOL you wish to send.
To view your account's transaction history and details, use the account command:
solana account <YOUR_ADDRESS>This will provide information about your account, including its transaction history.
The Solana CLI offers a wide array of commands for various operations on the Solana blockchain. Beyond the basics of creating wallets, transferring SOL, and checking balances, here are a few more commands that unlock additional functionalities:
To receive SOL for testing purposes on Devnet or Testnet, you can use the airdrop command. This is useful for development and testing without using real funds.
solana airdrop <AMOUNT> <YOUR_WALLET_ADDRESS> --url <NETWORK_URL>Replace <AMOUNT> with the number of SOL you want to receive, <YOUR_WALLET_ADDRESS> with your wallet address, and <NETWORK_URL> with the URL of Devnet or Testnet.
You can delegate SOL to a validator to participate in staking and earn rewards.
Create a Stake Account:
solana create-stake-account <STAKE_ACCOUNT_KEYPAIR_FILE> <AMOUNT> --from <FUNDING_SOURCE> --stake-authority <STAKE_AUTHORITY_PUBKEY> --withdraw-authority <WITHDRAW_AUTHORITY_PUBKEY>This command creates a new stake account with a specified amount of SOL.
Delegate Stake:
solana delegate-stake --stake-authority <STAKE_AUTHORITY_PUBKEY> <STAKE_ACCOUNT_ADDRESS> <VALIDATOR_VOTE_ACCOUNT_ADDRESS>Use this command to delegate your stake to a validator by specifying the stake account and the validator's vote account address.
Solana supports the creation of custom tokens through the SPL Token program.
Create a New Token:
spl-token create-tokenThis command creates a new token and outputs the token's mint address.
Create a Token Account:
spl-token create-account <TOKEN_MINT_ADDRESS>Creates a new account for holding tokens of the specified mint.
Minting Tokens:
spl-token mint <TOKEN_MINT_ADDRESS> <AMOUNT> <RECIPIENT_ACCOUNT_ADDRESS>Mint new tokens to a specified account.
To check the status of a transaction:
solana confirm <TRANSACTION_SIGNATURE>This command allows you to confirm that a transaction has been successfully processed.
Deploying a compiled program to the Solana blockchain:
solana program deploy <PROGRAM_FILEPATH>This is used for deploying smart contracts (or programs, in Solana terminology) to the network.
These commands represent just a fraction of what's possible with the Solana CLI. Each command has a variety of options and flags to customize its behavior, making the CLI a powerful tool for developers and users alike to interact with the Solana blockchain efficiently.
Note: By using the information in this post, the reader agrees to the terms of this disclaimer and acknowledges understanding the risks involved in using the Solana blockchain and its associated tools and technologies.
I have started a bit of a journey to discover the Solana blockchain and ecosystem. This here is a beginner's guide I've created from the knowledge I've learned from using the Solana Command Line Interface (CLI). The Solana CLI is a powerful tool that lets you interact with the Solana blockchain, enabling you to manage wallets, send transactions, and more. This tutorial will walk you through the basics to get you started.
A little warning, use of the Solana CLI and interaction with the Solana blockchain involves risks, including but not limited to loss of funds, security vulnerabilities, and regulatory implications. It is essential to know and understand the regulatory environment of your jurisdiction before engaging in blockchain-related activities.
First, you need to install the Solana CLI on your system. The process is straightforward and varies slightly depending on your operating system.
Open your terminal and run the following command:
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"Windows users should use the Windows Subsystem for Linux (WSL) and then run the same command as macOS and Linux users.
After installing, you can check if it was successful by running:
solana --versionThis command will display the version of Solana CLI installed.
Solana operates on different networks: Mainnet Beta, Testnet, and Devnet. To set your environment to one of these networks, use the config set command:
solana config set --url <network>Replace <network> with the appropriate URL for your desired network:
Mainnet Beta: https://api.mainnet-beta.solana.com
Testnet: https://api.testnet.solana.com
Devnet: https://api.devnet.solana.com
A wallet is essential for holding your SOL tokens and interacting with the Solana blockchain. To create a new wallet:
solana-keygen new --outfile ~/my-solana-wallet.jsonThis command creates a new wallet and saves the keypair to the specified file. Keep this file safe, as it contains your private keys.
To check the balance of your wallet, use:
This command will show the current balance of your SOL tokens.
You can send SOL to another address using the transfer command. Here's how:
solana transfer --from ~/my-solana-wallet.json <RECIPIENT_ADDRESS> <AMOUNT>Replace <RECIPIENT_ADDRESS> with the address of the recipient and <AMOUNT> with the amount of SOL you wish to send.
To view your account's transaction history and details, use the account command:
solana account <YOUR_ADDRESS>This will provide information about your account, including its transaction history.
The Solana CLI offers a wide array of commands for various operations on the Solana blockchain. Beyond the basics of creating wallets, transferring SOL, and checking balances, here are a few more commands that unlock additional functionalities:
To receive SOL for testing purposes on Devnet or Testnet, you can use the airdrop command. This is useful for development and testing without using real funds.
solana airdrop <AMOUNT> <YOUR_WALLET_ADDRESS> --url <NETWORK_URL>Replace <AMOUNT> with the number of SOL you want to receive, <YOUR_WALLET_ADDRESS> with your wallet address, and <NETWORK_URL> with the URL of Devnet or Testnet.
You can delegate SOL to a validator to participate in staking and earn rewards.
Create a Stake Account:
solana create-stake-account <STAKE_ACCOUNT_KEYPAIR_FILE> <AMOUNT> --from <FUNDING_SOURCE> --stake-authority <STAKE_AUTHORITY_PUBKEY> --withdraw-authority <WITHDRAW_AUTHORITY_PUBKEY>This command creates a new stake account with a specified amount of SOL.
Delegate Stake:
solana delegate-stake --stake-authority <STAKE_AUTHORITY_PUBKEY> <STAKE_ACCOUNT_ADDRESS> <VALIDATOR_VOTE_ACCOUNT_ADDRESS>Use this command to delegate your stake to a validator by specifying the stake account and the validator's vote account address.
Solana supports the creation of custom tokens through the SPL Token program.
Create a New Token:
spl-token create-tokenThis command creates a new token and outputs the token's mint address.
Create a Token Account:
spl-token create-account <TOKEN_MINT_ADDRESS>Creates a new account for holding tokens of the specified mint.
Minting Tokens:
spl-token mint <TOKEN_MINT_ADDRESS> <AMOUNT> <RECIPIENT_ACCOUNT_ADDRESS>Mint new tokens to a specified account.
To check the status of a transaction:
solana confirm <TRANSACTION_SIGNATURE>This command allows you to confirm that a transaction has been successfully processed.
Deploying a compiled program to the Solana blockchain:
solana program deploy <PROGRAM_FILEPATH>This is used for deploying smart contracts (or programs, in Solana terminology) to the network.
These commands represent just a fraction of what's possible with the Solana CLI. Each command has a variety of options and flags to customize its behavior, making the CLI a powerful tool for developers and users alike to interact with the Solana blockchain efficiently.
Note: By using the information in this post, the reader agrees to the terms of this disclaimer and acknowledges understanding the risks involved in using the Solana blockchain and its associated tools and technologies.
Grayman
Grayman
No activity yet