A java library for working with the Solana blockchain.

Overview

solanaj

Updated version of p2p-org/solanaj Solana blockchain client, written in pure Java. Solanaj is an API for integrating with Solana blockchain using the Solana RPC API

Full example

public static void main(String[] args) throws RpcException {

	Security.addProvider(new BouncyCastleProvider());

	String words = "swing brown camera enter burden awful rent shock mobile wisdom increase scissors";
	String passphrase = "carry";

	/**
	 * create account using mnemonic phrase
	*/
	Account account = Account.fromMnemonic(words, passphrase);
	System.out.println("address 1: " + account.getAddress());

	/**
	 * create account using mnemonic phrase, derivation path and address index
	*/
	DerivationPath derivationPath = new DerivationPathBuilder() //
			.withPurpose(Purpose.BIP84)//
			.withCoin(Coin.TSOL)//
			.withAccount(Long.valueOf(10L).hashCode())//
			.withChain(Chain.EXTERNAL)//
			.build();

	account = Account.fromMnemonic(words, passphrase, derivationPath, 1);
	System.out.println("address 2: " + account.getAddress());

	/**
	 * send a transaction
	 */
	RpcClient client = new RpcClient(Cluster.TESTNET);

	PublicKey fromPublicKey = new PublicKey("79M3HrgELA5Dnibjgir8UTkk8u9RkV3WhbkaqSjzVY3");
	PublicKey toPublickKey = new PublicKey("2Ym21uN3GqvFwkrvoWKwcTwqRjk1pFVSS6RFguNgmYdV");
	int lamports = Coin.TSOL.coinToFractions(BigDecimal.valueOf(1)).intValue();

	Transaction transaction = new Transaction();
	transaction.addInstruction(SystemProgram.transfer(fromPublicKey, toPublickKey, lamports));

	String hash = client.getApi().sendTransaction(transaction, account);
	System.out.println("transaction hash: " + hash);
	System.out.println("view on browser: " + String.format("https://solanabeach.io/transaction/%s?cluster=testnet", hash));

}

License

Solanaj is available under the MIT license. See the LICENSE file for more info.

You might also like...

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstall apk.

Tinker Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk. Getting started Add t

Dec 30, 2022

Trust-java - Test Results Verification library for Java

TRUST - Test Results Verification library for Java The TRUST's primary goal is to provide the simple way of different test results verification. Gener

Nov 19, 2017

Library for converting from one Java class to a dissimilar Java class with similar names based on the Bean convention

Library for converting from one Java class to a dissimilar Java class with similar names based on the Bean convention

Beanmapper Beanmapper is a Java library for mapping dissimilar Java classes with similar names. The use cases for Beanmapper are the following: mappin

Nov 15, 2022

Create a Music Playlist Library -Core JAVA, JAVA Swing, AWT

Project Specifications Manage Everything about a basic Music Playlist Application in Java A Music Library for Listing, Replaying, Navigating between c

Nov 8, 2022

Resconstruct is a java library to infer missing information vectors of java classes.

Reconstruct Resconstruct is a java library to infer missing information vectors of java classes. Features Phantom classes Inheritance solving Dummy fi

Nov 17, 2022

Z is a Java library providing accessible, consistent function combinators.

Fearless function combination in Java Techniques Unlock your functional programming potential with these combination techniques: Fusion Z.fuse(fn1, fn

Jun 13, 2022

This is a small library written in Java for minecraft login.

minecraft-auth-library This is a small library written in Java for minecraft login. Usage: Login with microsoft MinecraftAuthenticator minecraftAuthen

Feb 5, 2022

SpringBoot show case application for reactive-pulsar library (Reactive Streams adapter for Apache Pulsar Java Client)

Reactive Pulsar Client show case application Prerequisites Cloning reactive-pulsar Running this application requires cloning https://github.com/lhotar

Nov 10, 2022

A bitcoin explorer Java library that utilizes multiple data sources at once.

Bitcoin Explorer A bitcoin explorer library that utilizes multiple data sources at once. Branch Build Unit Tests master development Table of Contents

Jan 31, 2022
Owner
paymennt
paymennt
Ethereum blockchain-based e-portfolio management application built using Web3j API, java and solidity languages.

Web3j-Java-based e-Portfolio Manager Ethereum blockchain-based e-portfolio mangement application built using Web3j API, java and solidity languages. W

ibelab 6 Oct 1, 2022
jedibot is an application that aims to do beneficial actions on the Ethereum blockchain for the DeFi ecosystem while earning a profit for the user.

jedibot is an application that aims to do beneficial actions on the Ethereum blockchain for the DeFi ecosystem while earning a profit for the user. These actions include maintaining the DAI peg, providing liquidity and liquidating undercollateralized assets.

我是高天才! 10 Feb 5, 2022
MarioCash is a trust-based multi-dimensional blockchains built with a vision to connect everything and any blockchain networks.

MarioCash We will change the world by blockchain. What is mariocash? MARIOCASH is a trust-based multi-dimensional blockchains (branches) built with a

Brantley·Williams 23 Mar 10, 2022
BlockChain Pipeline using Jenkins for DevOps

BlockChain Pipeline for Jenkins This project is inspired by the work of Redback and Microsoft teams for developing the process using VSTS. I've chosen

Brantley·Williams 11 Jun 8, 2022
A blockchain system to manage monetary transactions between the different nodes of a decentralized network.

Blockchain under a clear vision A blockchain system to manage monetary transactions between the different nodes of a decentralized network. Authors @s

SamDik 3 Jun 9, 2022
[WIP] Springram is uber library for working with Telegram using Spring Framework and Spring Boot.

Springram Springram is a library for working with telegram using the spring framework and spring boot. This library gives you the ability to use contr

Max 6 Nov 1, 2022
🍀 Utilities for working with the Spigot library

?? VettherUtilities Spigot utilities for versions: 1.14, 1.15, 1.16, 1.17, 1.18 Require Java 11 or higher. Use older versions at your own risk! Featur

Vetther 4 Oct 17, 2022
Served as the team leader to collaborate with another intern for a project and drew up our working schedule

Served as the team leader to collaborate with another intern for a project and drew up our working schedule, risk management plan, quality control plan, configuration management plan, etc Compiled codes for the front end and back end, composed the development documentation and explored SSM structure and MyBatis structure.

bright spark 2 Jan 17, 2022
An example of how to working with paging in Spring for GraphQL / Spring Data JPA

Spring for GraphQL Paging This repo contains the code for a live coding session I did on: Spring Data JPA GraphQL Paging & Sorting The reason I put th

Dan Vega 10 Nov 28, 2022
A React Native Template for installing a working ClojureScript, Krell, and Storybook environment

A React Native Template for ClojureScript, Krell, and Storybook Getting Started npx react-native init YourProjectName --template react-native-template

Joshua Miller 30 Dec 23, 2022