GitHub Repository

Dependencies

Features

Private Key Parsing

Usage

var jsonConfig = "";
var ji = JsonIterator.parse(jsonConfig);
var signer = PrivateKeyEncoding.fromJsonPrivateKey(ji);

JSON Configuration

If the base58 encoded public key is configured via pubKey it will be used to further validate the public key derived from the private key.

Solana CLI Key Pair JSON Array

By default, if only an array is configured, the assumption is that it is a key pair generated by the Solana CLI.

[1,2,3, ... ,42]

JSON Array

{
  "pubKey": "<BASE58_ENCODED_PUBLIC_KEY>",
  "encoding": "jsonKeyPairArray",
  "secret": []
}

Key Pair

Encoded 64 byte private/public key pair. Derived public key will be validated.

  • base64KeyPair
  • base58KeyPair
{
  "pubKey": "<BASE58_ENCODED_PUBLIC_KEY>",
  "encoding": "base64KeyPair",
  "secret": "asdf=="
}

Private Key Only

Encoded 32 byte private key.

  • base64PrivateKey
  • base58PrivateKey
{
  "pubKey": "<BASE58_ENCODED_PUBLIC_KEY>",
  "encoding": "base64PrivateKey",
  "secret": "asdf=="
}

Transaction Deserialization

The TransactionSkeleton interface provides a lightweight view over transaction data. Allowing for partial introspection or complete reconstruction of a Transaction.

Legacy

byte[] legacyTransactionData = ...;
var skeleton = TransactionSkeleton.deserializeSkeleton(legacyTransactionData);
AccountMeta[] accounts = skeleton.parseAccounts();
Instruction[] instructions = skeleton.parseLegacyInstructions();
Transaction transaction = skeleton.createTransaction()

Versioned

byte[] v0TransactionData = ...;
var skeleton = TransactionSkeleton.deserializeSkeleton(v0TransactionData);
var instructionsWithoutTableAccounts = skeleton.parseInstructionsWithoutTableAccounts();

PublicKey[] tableAccounts =  skeleton.lookupTableAccounts();
// ... Fetch table accounts (See RPC) ...
AddressLookupTable lookupTable = ...;
AccountMeta[] accounts = skeleton.parseAccounts(lookupTable);
Instruction[] instructions = skeleton.parseInstructions(accounts);
Transaction transaction = skeleton.createTransaction(instructions, lookupTable);

Creating Transactions

See the program docs for typical transaction flows.