You can find ready-to-use Java examples of sol4k APIs. Each class in this repository is a complete example that you can load and run without any additional setup.
- Sending a SOL transfer transaction.
- Sending a SOL transfer transaction (Legacy Transaction).
- Sending a transaction with multiple instructions.
- Creating an Associated Token Account.
- Transferring SPL tokens.
- Getting Wallet Balance.
- Getting SPL Token Balance.
- Request Airdrop.
Check the main Sol4k repository to find information on how to add Sol4k to your existing codebase.
To ensure that the examples are readily usable, they include the private key of the test account. However, it is important to note that committing your private keys to version control is never recommended for real projects, and is only done here for convenience purposes.
As anyone has access to the private key of the test account,
which is 2mjCPF5ABp6CVAYHd5azz5A8cKQUqqvuiT5NJ4wpAjCc
, it may
run out of funds. If you encounter issues with some of the
examples, please ensure that this account has sufficient funds,
either in SOL or USDC. You can use this code
snippet
to send Devnet SOL, while for USDC, you can utilize
this faucet.