Skip to main content

Getting started

Why this matters​

The SDK is how a business puts Varnir inside its own product: take payments into wallets it controls, pay out, trade, raise invoices, and hand an AI agent a key that can only spend within limits set on the ledger. Keys are made and used in your own process, so Varnir never holds the key that signs for you.

Pick a language​

TypeScript is the reference SDK. The others are ports that follow the same core contract, so amounts, network codes and error codes mean the same thing in every language.

LanguagePackage
TypeScript@varnir/chain-client
Pythonvarnir
Kotlin / Javavarnir-sdk
C# / .NETVarnir.Sdk
Gosite.varnir/sdk
PHPvarnir/sdk
Rustvarnir-sdk
Dart / Fluttervarnir
SwiftVarnir

Not every port covers every method yet. The overview lists what each one supports and how to install it.

The flow in five steps​

Every integration follows the same path, whichever language you use:

  1. Get a key. Generate a recovery phrase and derive a private key from it, in your own process. Store the phrase: it is the only way back to the identity.
  2. Onboard. Put the identity on the ledger. This is idempotent, so it is safe to call every time your process starts.
  3. Get a wallet. Ask for a deposit address on a network such as Tron Nile.
  4. Send or invoice. Pay out, or raise an invoice that a customer pays.
  5. Get told. Set a deposit callback so your server hears about payments.

In TypeScript, steps 1 to 4 look like this:

import {VarnirClient, VarnirChain} from '@varnir/chain-client';
import {generateRecoveryPhrase, derivePrivateKeyFromPhrase} from '@varnir/chain-client/keys';

const phrase = generateRecoveryPhrase();
const {privateKeyHex} = derivePrivateKeyFromPhrase(phrase);

const client = await VarnirClient.onboard({network: 'testnet', privateKeyHex});
const wallet = await client.getWallet(VarnirChain.TronNile);
const invoice = await client.createInvoice({
wallets: [wallet],
name: 'First invoice',
amount: '10',
});

console.log(invoice.url); // https://scanner.varnir.site/pay/<id>

'testnet' is the entire configuration: you never name a hostname, a contract id or a transaction shape. The TypeScript guide goes through each step in full, and each language page shows its own version.

Try it without installing anything​

Every snippet on the playground runs this same API live in a browser tab, against the public testnet.

Next​