Skip to content
Logo

SDK example setup

Choose Rust or TypeScript to run the perps maker example. Follow the installation steps below, then download and build the example, configure your keys and network, and return to Create and fund the account.

The examples use SDK 7.0.4 / IDL 0.10.2. Your Flint contact must confirm the matching program and SDK for your network. The examples check program identity. disable-rpc checks through RPC instead of the gateway.

Install

Use macOS, Linux or WSL2. Run WSL2 commands inside its Linux environment.

ExampleTools
RustRust 1.89+, a C compiler and Protocol Buffers (protoc)
TypeScriptNode.js 22 and npm
BothSolana CLI for wallet keys

For Rust, also install the build tools for your platform:

  • macOS: Xcode command-line tools and Homebrew protobuf.
  • Ubuntu or WSL2: build-essential, pkg-config and protobuf-compiler.

Package access

For Rust, open Perps → Developer → Get SDK credentials to get an SDK access token. The server creates a Kellnr token on first use and reuses it on later requests. Contact Flint if issuance fails.

Add this section to ~/.cargo/config.toml. Preserve existing settings and avoid duplicate sections.

[registries.kellnr]
credential-provider = "cargo:token"
index = "sparse+https://kellnr.xantasoft.com/api/v1/crates/"

Then authenticate to the registry for your language:

cargo login --registry kellnr
# Paste the dashboard token at the prompt.

For TypeScript, your GitHub account needs access to the maker SDK, margin user SDK, spot SDK dependency and flint-idl. A Kellnr token does not grant npm access. Resolve any install 401/403 with your Flint contact before continuing.

Download and build

The canonical examples live in flint-api-client/examples/margin-maker: browse the Rust source or TypeScript source, or download an archive below.

Download the ZIP for your language and extract it into a new directory named maker. The archive contains a rust or typescript subdirectory.

LanguageDownload
RustRust example ZIP
TypeScriptTypeScript example ZIP
cd maker/rust
cargo build --locked

Keep the lockfile and use the pinned versions for later runs.

Keys and configuration

The bot uses QUOTER_KEYPAIR. Set OWNER_KEYPAIR only if you use the example for owner actions such as setup, deposits or withdrawals. Dashboard owner actions use your connected wallet instead.

For file-key use, set OWNER_KEYPAIR to an existing owner key file. If you need a new owner, create a separate file. Do not overwrite an existing wallet. Create a fresh bot key. Keep both files outside the source repository.

mkdir -p "$HOME/.config/solana"
# Run this owner command only when you need a new owner key.
solana-keygen new --no-bip39-passphrase --outfile "$HOME/.config/solana/perps-owner.json"
solana-keygen new --no-bip39-passphrase --outfile "$HOME/.config/solana/perps-quoter.json"

Configure the example

Set these values in the example's shell. Use the configuration supplied by your Flint contact. The loopback URLs below work only with the running local fixture; replace them for another network.

Skip the OWNER_KEYPAIR export if you use the dashboard for owner actions. Otherwise, replace its example filename with your actual owner key path.

Keep TRADER_ID as a decimal string: it is an unsigned 64-bit ID, separate from your wallet address and PERP_ID. COLLATERAL_ATOMS uses the mint's smallest unit: 10 tokens of a six-decimal mint is 10000000 atoms.

export RPC_URL=http://127.0.0.1:8899
export MAKER_ENDPOINT=http://127.0.0.1:15062
export PUBLIC_ENDPOINT=http://127.0.0.1:15061
export OWNER_KEYPAIR="$HOME/.config/solana/perps-owner.json"
export QUOTER_KEYPAIR="$HOME/.config/solana/perps-quoter.json"
export TRADER_ID='<reserved-id>'
export PERP_ID='<selected-perp-id>'
export COLLATERAL_MINT='<supported-mint>'
export COLLATERAL_ATOMS='<integer-atoms>'

Fee sponsorship and local funding

Check the bot address with the QUOTER_KEYPAIR command. Run the OWNER_KEYPAIR command only for SDK owner actions:

solana-keygen pubkey "$OWNER_KEYPAIR"
solana-keygen pubkey "$QUOTER_KEYPAIR"

Flint provides fee SOL for maker wallets. The examples use the signing wallet as fee payer; they do not use the separate trader transaction-sponsorship route. Owner actions that create accounts can also require SOL for rent.

The local fixture supplies synthetic SOL. If you use new keys on that fixture, use the airdrops below. If you use the dashboard for owner actions, run only the airdrop command that uses QUOTER_KEYPAIR. Run these commands only on the local fixture:

solana airdrop 1 --url "$RPC_URL" --keypair "$OWNER_KEYPAIR"
solana airdrop 1 --url "$RPC_URL" --keypair "$QUOTER_KEYPAIR"

Obtain collateral separately. A SOL airdrop does not supply USDC or wrapped SOL.

Choose quote inputs

Run markets to read the selected perp's grid, mark statistics and collateral metadata. Match the records by perp ID. If the mark is missing or stale, ask your Flint contact to restore the feeds before testing a fill.

The API's tick_size is the price step per base unit. For example, if the selected market has a price step of 0.001 USDC/SOL and a lot size of 0.001 SOL, a bid of 149.900 and an ask of 150.100 are 149900 and 150100 ticks. A size of 0.010 SOL is 10 lots. These are calculation examples; select prices near your market's current mark and a size your collateral can support.

Convert with decimal arithmetic. Round bid prices down and ask prices up to the grid. Require a whole number of lots. Do not copy inputs from another market.

Prices and quantities in the example commands must be positive UInt32 integers, with the ask above the bid. Quote expiry is measured in slots.

Delegate expiry

The example's setup grants Trade + Quote with expiry 0 (no expiry). To use an expiring grant, change expiry_unix_seconds (Rust) or expiryUnixSeconds (TypeScript) in the source to an absolute Unix timestamp before granting a fresh key. An expired or revoked key cannot be re-granted. See Key hygiene.

Return to Maker onboarding for setup, quoting and fill verification. Commands and recovery lists every command.