Flutter / Dart

Get Started or Add to an Existing Project

Getting started with Kinetic is incredibly straightforward. Just follow the steps below to start transacting with a token in your app.

Installation

Add the package to your pubspec.yaml file below dependencies.

kinetic: ^1.0.0-rc.1

Visit pub.dev/packages/kinetic for other versions.

Instantiate the Kinetic Client

The Kinetic Client will give you access to all the methods you need to work with a token on the blockchain.

We recommend starting with Devnet before moving on to Mainnet.

KineticSdkConfig sdkConfig = KineticSdkConfig(
  index: 1,
  endpoint: 'https://kinny-kinetic.azurewebsites.net',
  environment: 'devnet',
  logger: Logger(),
);
KineticSdk sdk = await KineticSdk.setup(sdkConfig);

Don't have an App Index? Register your app on our Onboarding Form so you can get your App Index that allows you to transact with our SDKs.

While you're waiting for confirmation of your App Index, use 1 on devnet so you can get started.

Create Account

You can create accounts randomly or from existing mnemonics or secret keys. Below, we'll make a keypair and use that for creating an account on the blockchain.

Keypair owner = await Keypair.random();

CreateAccountOptions options = CreateAccountOptions(
  owner: owner,
  mint: mint,
  commitment: CreateAccountRequestCommitmentEnum.finalized,
  reference: 'test',
);

Transaction? transaction = await sdk.createAccount(options);

Close Account

It's good practice to close unneeded accounts. You can only close accounts that you have created and are currently empty.

CloseAccountOptions options = CloseAccountOptions(
  account: owner.publicKey,
  commitment: CreateAccountRequestCommitmentEnum.finalized,
);
CloseAccountResponse? res = await sdk.closeAccount(options: options);

Check Balance

Check a user balance by passing in the public key of the account you want to check.

The response object includes your total balance as well as detailing all of the Mints and Tokens held by that Public Key.

GetBalanceOptions options = GetBalanceOptions(account: owner.publicKey);
BalanceResponse? res = await sdk.getBalance(options: options);
dynamic res = await kinetic.getBalance(kinetic.keypair.solanaPublicKey.toBase58());

Airdrop Funds (devnet)

Send some test funds to a specific Public Key on Devnet.

RequestAirdropOptions options = RequestAirdropOptions(
  account: owner.publicKey,
  mint: mint,
  amount: "10",
  commitment: RequestAirdropRequestCommitmentEnum.finalized,
);
RequestAirdropResponse? res = await sdk.requestAirdrop(options);

Transfer a Token

Transfer a token from a Keypair to any Public Key.

Keypair alice = await Keypair.random();

MakeTransferOptions options = MakeTransferOptions(
  amount: "1.0",
  destination: alice.publicKey,
  commitment: MakeTransferRequestCommitmentEnum.finalized,
  mint: mint,
  owner: owner,
  reference: "some-ref",
  type: TransactionType.p2p,
  senderCreate: false,
);

Transaction? transaction = await sdk.makeTransfer(options);

Get Transaction Details

Get the details of any transaction by passing in the transaction signature.

GetTransactionOptions options = GetTransactionOptions(signature: transaction.signature!)
GetTransactionResponse? res = await sdk.getTransaction(options);

Get Solana Explorer URL

Solana Explorer

String? res = await sdk.getExplorerUrl("account or transaction id string");

Get Account History

Get the full transaction history of any account by passing in the account's Public Key.

GetHistoryOptions options = GetHistoryOptions(account: alice.publicKey, mint: mint);
List<HistoryResponse>? res = await sdk.getHistory(options);

Get Account Info

Easily get the main info of any account by passing in the account's Public Key.

GetAccountInfoOptions options = GetAccountInfoOptions(account: alice.publicKey, mint: mint);
List<AccountInfoResponse>? res = await sdk.getAccountInfo(options);

Get Token Accounts

Get the full list of Token Accounts held by a Keypair on Solana.

GetTokenAccountsOptions options = GetTokenAccountsOptions(account: alice.publicKey, mint: mint);
List<TokenAccountsResponse>? res = await sdk.getTokenAccounts(options);

Webhooks

Access Kinetic Manager to manage your app's settings.

This includes allowing you to configure your app to use a number of webhooks.

Balance Webhook

The balance webhook allows you to receive an alert when your app's hotwallet is running low on Sol so you can top it up and ensure your app can continue to keep transacting.

Balance Webhook

E.g. In a node express server:

app.use('/balance', async (req, res) => {
  const data = req.body
  // DO STUFF WITH THE BALANCE ALERT
  res.sendStatus(200)
})

Event Webhook

The event webhook allows you to receive alerts when actions have been confirmed on the Solana blockchain.

Balance Webhook

E.g. In a node express server:

app.use('/events', async (req, res) => {
  const event = req.body
  // DO STUFF WITH THE EVENT DATA
  res.sendStatus(200)
})

Verify Webhook

The verify webhook allows you to have fine-grained control over transactions, making sure they meet your own criteria before allowing them to proceed.

Balance Webhook

E.g. In a node express server return a 200 status code to approve the transaction or a 400 to reject it:

app.use('/verify', async (req, res) => {
  const transaction = req.body
  // CHECK THAT YOU WANT THIS TRANSACTION TO PROCEED
  // e.g.
  if (transaction.amount < 1000000) {
    res.sendStatus(200)
  }
  res.sendStatus(400)
})

Demos and Starter Kits

Created to help get you up and running as quickly as possible, these projects can be a great reference point when you get stuck or even a starter for your own project. Happy coding!

Kinetic Dart SDK Starter app

A simple app that allows you to create keypairs, create an account, transfer a token, and view your balance and account history.

Ready for Production?

If your app is ready for production, this is the place for you!

Production

Get your app ready and running on the Solana Mainnet

Contribute

Kinetic Dart SDK

Want to contribute to the Kinetic Dart SDK?

What If I Get Stuck?

Kinny Discord

Join our community.


Was this page helpful to you?
Provide feedback