The Solana SDK for Dart & Flutter

Build on Solana in typed Dart.

A full port of @solana/kit: addresses, codecs, RPC, subscriptions, transactions, signers, and program clients, written with records, sealed classes, and extension types.

dart pub add solana_kit
  1. InstructiongetAddMemoInstruction(…)
  2. MessagecreateTransactionMessage(…)
  3. SignedsignTransactionWithSigners(…)
  4. ConfirmedsendAndConfirmTransaction(…)
typed at every step

Examples

Real code, straight from the repo

Every snippet below is cut from a runnable file in examples/, which CI analyses on every change, so it cannot drift from the API.

Fetch on-chain state

Create an RPC client, then ask for an account. The response carries its context slot and a value that is null when the account does not exist.

  • Every RPC method returns a pending request you send when ready
  • Typed configs such as GetAccountInfoConfig instead of raw maps
  • Missing accounts are a null value, not an exception
15_get_account_info.dart
final rpc = createSolanaRpc(url: 'https://api.devnet.solana.com');

const systemProgram = Address('11111111111111111111111111111111');

final typedInfo = await rpc
    .getAccountInfoValue(
      systemProgram,
      GetAccountInfoConfig(encoding: AccountEncoding.base64),
    )
    .send();

final account = typedInfo.value;

if (account != null) {
  print('\nSystem program exists.');
  print('  owner     : ${account['owner']}');
  print('  lamports  : ${account['lamports']}');
  print('  executable: ${account['executable']}');
}

Build, sign, send, confirm

Transaction messages are immutable values you build up step by step, then compile, sign with any signer, and confirm.

  • A fluent, immutable message builder
  • Signers are interfaces, so key pairs and wallets are interchangeable
  • Confirmation strategies are built in
23_transaction_send_and_confirm.dart
final payer = generateKeyPairSigner();

final blockhashResult = await rpc.getLatestBlockhashValue().send();
final blockhash = blockhashResult.value;

const memoProgram = Address('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
final memoData = Uint8List.fromList('Hello devnet!'.codeUnits);

final message = createTransactionMessage(version: TransactionVersion.v0)
    .withFeePayer(payer.address)
    .withBlockhashLifetime(
      BlockhashLifetimeConstraint(
        blockhash: blockhash.blockhash.value,
        lastValidBlockHeight: blockhash.lastValidBlockHeight,
      ),
    )
    .appendInstruction(
      Instruction(
        programAddress: memoProgram,
        accounts: [
          AccountMeta(
            address: payer.address,
            role: AccountRole.readonlySigner,
          ),
        ],
        data: memoData,
      ),
    );

final transaction = compileTransaction(message);
final signed = await signTransactionWithSigners([payer], transaction);

final sig = await sendAndConfirmTransaction(rpc: rpc, transaction: signed);

Subscribe over WebSockets

Subscriptions are Dart streams. Pass a cancellation token to tear the socket subscription down cleanly.

  • Channel pooling and autopinging out of the box
  • Cancellation tokens instead of dangling listeners
  • Every notification method from the Solana RPC
16_rpc_subscriptions.dart
final rpcSubscriptions = createSolanaRpcSubscriptions(
  'wss://api.devnet.solana.com',
);

final controller = CancellationTokenSource();

final pending = rpcSubscriptions.slotNotifications();

final stream = await pending.subscribe(
  RpcSubscribeOptions(abortSignal: controller.token),
);

Describe byte layouts with codecs

Compose small codecs into a struct that encodes and decodes an account layout. Field order is byte order.

  • Numbers, strings, arrays, options, enums, and structs
  • Fixed and variable sizes that you can see in the types
  • The same codec model as @solana/kit, in idiomatic Dart
07_struct_codec.dart
final mintCodec = combineCodec(
  fixEncoderSize(getBase58Encoder(), 32),
  fixDecoderSize(getBase58Decoder(), 32),
);

final tokenAccountCodec = getStructCodec([
  ('mint', mintCodec), // 32 bytes
  ('owner', mintCodec), // 32 bytes
  ('amount', getU64Codec()), // 8 bytes (BigInt)
  ('isInitialized', getBooleanCodec()), // 1 byte
]);

final encoded = tokenAccountCodec.encode(account);

final decoded = tokenAccountCodec.decode(encoded);

Call programs through typed clients

Generated program clients build instructions and multi-step instruction plans, with every account named.

  • System, Token, Token-2022, Stake, Memo, Metaplex, and more
  • Instruction plans for flows that span several transactions
  • Generate your own client from an IDL with the Codama renderer
28_program_clients.dart
final instruction = getAddMemoInstruction(
  programAddress: memoProgramAddress,
  memo: 'hello from solana_kit',
);

final delegate = getDelegateStakeInstructionPlan(
  stake: account,
  vote: secondAccount,
  stakeAuthority: authority,
);

Derive program addresses

Program-derived addresses come back as a record of address and bump, ready to destructure.

  • Address is an extension type: free at runtime, checked at compile time
  • String and byte seeds
  • Curve checks for keys and PDAs
04_program_derived_address.dart
final (vaultPda, vaultBump) = await getProgramDerivedAddress(
  programAddress: systemProgram,
  seeds: ['vault', 'user-42'],
);

final onCurve = isOnCurveAddress(vaultPda);

Why Solana Kit

Everything @solana/kit does, the Dart way

Start here

Pick your path

Get started

Install the SDK and send a first transaction.

Core concepts

How the pieces of the SDK fit together.

Guides

End-to-end walkthroughs for real integrations.

Flutter & mobile

Wallets, UI kits, and app distribution.

Programs

Typed clients for on-chain programs.

Reference

Packages, versions, and upstream parity.

Contributing

Work on the SDK itself.

Package map

Small packages, one toolkit

Each layer is its own package with its own changelog. Here are the ones you will reach for first.

Browse all 68 packages in the catalog →

Ready to ship?

solana_kit 0.11.1 is on pub.dev. Add it, then follow the quick start.