Solana Token Swap with solv CLI
The solv swap
command is a tool that allows you to swap Solana Tokens/SPL Tokens simply and intuitively.
You can select tokens interactively and execute swaps, or complete swaps quickly using a one-liner command, making token swap operations easy to integrate into your programs.
This solv swap is offered with 0% fees , and by utilizing the private RPC and Jupiter API endpoints provided by Validators Solutions, it ensures fast and reliable connectivity.
This enables a smooth and efficient trading experience.
Initial setup of solv swap command
When you run the following command, a prompt will appear,
solv swap ? Enter Solana RPC URL https://rpc.validators.solutions/rpc?api-key=<YOUR_API_KEY> ? Enter Keypair Path /home/solv/mainnet-validator-keypair.json ? Enter Jupiter API Key(Optional)
By entering the following information, the settings will be saved in solv4.config.json
, and you will be able to execute the swap.
-
RPC_URL
- Solana RPC URLThis RPC URL is the Solana RPC URL used to connect to the Solana network. This URL is used to connect to the Solana node.
-
KEYPAIR_PATH
- Path to the Keypair fileThe Keypair file is the file path of the Solana Keypair used for token swaps.
-
API_KEY
- API Key to access Jupiter API (Optional)This API key is the Jupiter API key used to access the Jupiter API. It can be used even if it is blank, but obtaining an API key provides a faster and more reliable connection.
Executing the solv swap command
When you run the following command, a prompt will appear, and you can enter the information of the token to be swapped.
First, select the Input Mint, and
solv swap ? Select input mint β― SOL USDC elSOL JitoSOL mSOL bSOL EPCT
Then, select the Output Mint, and
solv swap ? Select output mint elSOL JitoSOL mSOL bSOL EPCT JUP
If you select Other, you can enter the Mint address directly.
? Enter output mint address (ELSoL1owwMWQ9foMsutweCsMKbTPVBD9pFqxQGidTaMC)
next, enter the amount to swap.
? Enter input amount in LAMPORTS. e.g. 0.01 SOL 10000000
This value is entered in lamports
.
Note: The decimal may vary depending on the token, so be careful.
Finally, a confirmation screen will appear, and you will be asked whether to execute the swap. If you select Yes, the swap will be executed.
Once the transaction is sent, the swap is completed, and the transaction hash is displayed.
You can check the transaction status on the Solana Explorer or any other Solana block explorer.
solv Swap One-liner Command
The command executed above can also be run as a one-liner command.
When you obtain an estimate, a one-liner command is also displayed. By executing that command, you can perform the swap immediately without going through the interactive prompt.
solv swap --input So11111111111111111111111111111111111111112 --output EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v --amount 10000000 --skip-confirm
his command includes the --skip-confirm
option, allowing the swap to be executed without a confirmation screen.
It is an effective option when automating tasks, such as BOT trading.
This solv swap operates with 0% fees , and by utilizing private RPC, it provides fast and reliable connectivity.
π Free API Key Exclusive to the Validators DAO Community
We're excited to offer a free API key exclusively for the Validators DAO community π It's our way of supporting the community and empowering you with fast, reliable connections.
To get your free API key, simply join us through the link below:
π Validators DAO: https://discord.gg/8dhnZnvzuw
Unlock fast connections and elevate your experience with your very own API key π
How to Use the RPC API Key
You can use the RPC API key by adding it to the RPC URL as shown below:
Your RPC URL will look like this:
https://rpc.validators.solutions?api-key=<YOUR_API_KEY>
If you are using the Solana CLI, you can use it as follows by adding the --url
option:
e.g.
solana balance --url https://rpc.validators.solutions?api-key=<YOUR_API_KEY>
How to Use the Jupiter API Key
For the Jupiter API key, include it in the headers as a Bearer
token when sending requests.
Jupiter Quote API endpoint:
GET: https://jup.validators.solutions/v1/jup/quote
Jupiter Swap API endpoint:
POST: https://jup.validators.solutions/v1/jup/swap
Example of Getting a Swap Quote: To get a quote for swapping 0.01 SOL to USDC:
curl --location 'https://jup.validators.solutions/v1/jup/quote?inputMint=So11111111111111111111111111111111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=10000000' \ --header 'Authorization: Bearer <YOUR-API-KEY>'
In the example above, the Authorization header
includes Bearer <YOUR-API-KEY>
, and the request includes query parameters such as inputMint
, outputMint
, and amount
.
The amount represents the input token quantity in lamports
.
Please note that decimals differ depending on the token.
β»The RPC API key and Jupiter API key are the same value, but they are used differently for each API.
solv swap Command Options
solv swap --help Usage: solv swap [options] Swap tokens Options: -i, --input <input> Input token mint (default: "") -o, --output <output> Output token mint (default: "") -a, --amount <amount> Input amount in lamports (default: "0") -s, --skip-confirm Skip confirmation (default: false) -h, --help Display help for command