Solard

Client methods

Public Solard client methods.

Construction and lifecycle

createSolard(options?)

Create the public Solard client. Importing the module alone does not create persistence.

ts
function createSolard(options: SolardOptions = {}): Solard

type SolardOptions = {
  rpcUrl?: string;
  dbPath?: string;
  cacheTtlMs?: number;
};
OptionTypeDefaultMeaning
rpcUrlstring?—Optional RPC endpoint override passed to the core Solard connection layer.
dbPathstring?—Optional SQLite database path override.
cacheTtlMsnumber?—Optional account-cache TTL override.

Returns: A frozen Solard object exposing only the curated public methods and nested APIs documented here.

createTraderSolard

Alias for <code>createSolard</code>; no extra methods.

ts
const createTraderSolard = createSolard

close()

Close the underlying Solard instance and database/connection resources owned by the client.

ts
close(): void

Wallet methods

Wallet methods expose public metadata. Signing does not expose private keys or raw signer objects.

createWallet

Generate a new Solana keypair and persist it encrypted in the canonical Solard database.

ts
createWallet(name?: string): WalletInfo
OptionTypeDefaultMeaning
namestring?—Optional stored wallet alias.

Returns: WalletInfo with public metadata only.

ts
const wallet = slrd.createWallet("maker");
console.log(wallet.address);

createVanityWallet

Search for a public-key suffix, persist the matching keypair as an encrypted wallet, and return generation statistics.

ts
createVanityWallet(
  name: string | undefined,
  options: VanityMintOptions,
): Promise<{
  wallet: WalletInfo;
  suffix: string;
  attempts: number;
  elapsedMs: number;
  ratePerSecond: number;
  lastMint: string;
}>

type VanityMintOptions = {
  suffix: string;
  maxAttempts?: number;
  timeoutMs?: number;
  reportEvery?: number;
  onProgress?: (progress: VanityMintProgress) => void;
  workers?: number;
  signal?: AbortSignal;
};
OptionTypeDefaultMeaning
namestring | undefined—Stored wallet alias.
options.suffixstring—Required public-key suffix target.
options.maxAttemptsnumber?—Optional attempt budget.
options.timeoutMsnumber?—Optional wall-clock timeout.
options.reportEverynumber?—Progress callback interval.
options.workersnumber?—Parallel vanity workers.
options.signalAbortSignal?—Abort the generation search.

importWallet

Parse a base58 or JSON byte-array private key and persist it encrypted in the wallet database.

ts
importWallet(privateKey: string, name?: string, options?: { overwrite?: boolean }): WalletInfo
  • Same-address re-imports can update without overwrite. Replacing a different wallet that already uses the requested name requires overwrite=true.
OptionTypeDefaultMeaning
privateKeystring—Base58 secret key or JSON array of secret-key bytes.
namestring?—Optional wallet alias.
options.overwriteboolean?falseAllow replacing a different wallet that already uses the requested name.

Returns: WalletInfo.

listWallets

List every stored wallet as public metadata without exposing encrypted-secret fields.

ts
listWallets(): WalletInfo[]

Returns: Array of WalletInfo.

Do not cast createSolard() to expose core-only signers, connections, or repositories.

Token registry and account methods

addToken

Read the mint, inspect it through registered venue adapters, and upsert the resulting token record.

ts
addToken(mintRef: string, name?: string, metadata: Partial<TokenRow> = {}): Promise<TokenRow>
  • The method reads on-chain decimals/token program, merges venue inspection fields, then applies supplied metadata and stores refreshedAtMs.
OptionTypeDefaultMeaning
mintRefstring—Base58 token mint address.
namestring?—Optional human alias/name override.
metadataPartial<TokenRow>{}Additional persisted token metadata merged after inspection.

Returns: The persisted TokenRow.

resolveToken

Resolve a stored token by supported reference form. This does not automatically add an unknown mint.

ts
resolveToken(ref: TokenRef): TokenRow

Returns: Stored TokenRow or an unknown-token error when no registry entry matches.

tokenAccounts

List actual token accounts owned by a wallet across both the classic Token program and Token-2022.

ts
tokenAccounts(ref: WalletRef): Promise<OwnedTokenAccount[]>
  • Each returned account includes address, mint, owner, raw amount, decimals, token program, lamports, associated-account status, account state, and close authority.

Returns: Array of OwnedTokenAccount records.

snapshotHolders

Take a complete on-chain holder snapshot suitable for payout denominators and accounting.

ts
snapshotHolders(token: TokenRef, options?: Omit<TokenHolderSnapshotOptions, 'token'>): Promise<TokenHolderSnapshot>
  • The underlying snapshot reads token-program accounts directly rather than stitching websocket deltas.
  • Solard automatically passes stored Pump/PumpSwap token metadata into the lower-level snapshot primitive so curve, pool, and sharing-config inventory can be excluded when known.
OptionTypeDefaultMeaning
tokenTokenRef—Stored token reference.
commitmentconfirmed|finalized?confirmedSnapshot commitment.
excludeOwnersIterable<string|PublicKey>?—Explicit owner addresses excluded from the eligible denominator.
minimumRawbigint?1nExclude balances below this raw-token threshold.

Returns: TokenHolderSnapshot with supply, holder counts, eligible/excluded totals, holder rows, and excluded rows.

walletBalances

Read confirmed SOL balance plus balances for the supplied token references.

ts
walletBalances(ref: WalletRef, tokenRefs?: TokenRef[]): Promise<WalletBalanceSnapshot>
  • When tokenRefs is omitted in core, the method uses the stored token registry. It also refreshes missing decimals when necessary and records position balances in Solard's internal position store.

Returns: { wallet, solLamports, tokenBalances, capturedAtMs }.

Market and trading methods

samplePrice

Resolve the token's venue, sample its current quote-per-token price, and persist that price sample.

ts
samplePrice(token: TokenRef): Promise<MarketPrice>

Returns: MarketPrice containing venue, mint, quote asset, priceQuotePerToken, optional reserve values, and capturedAtMs.

buy

Build, simulate by default, submit, and confirm a routed native Solard buy for one wallet.

ts
buy(
  token: TokenRef,
  wallet: WalletRef,
  amount: HumanAmount,
  options?: {
    slippageBps?: number;
    via?: SenderId;
    skipSimulation?: boolean;
    skipPreflight?: boolean;
  },
): Promise<SendReceipt>
  • The public SDK buy method is an execution method, not a quote-only method. It calls the transaction composer and sends immediately.
  • When a PumpSwap preflight fails with the specific retryable 6040 simulation error, the core method rebuilds exactly once so the pool/fee quote is fresh while preserving the requested slippage.
  • The SDK wrapper does not impose the CLI's 1500-bps default; omitted options flow to the underlying composer/venue behavior.
OptionTypeDefaultMeaning
tokenTokenRef—Registered token to buy.
walletWalletRef—Stored signing wallet reference.
amountHumanAmount—SOL or raw quote-asset amount accepted by the routed market.
options.slippageBpsnumber?—Optional slippage override.
options.viaSenderId?rpcSender lane.
options.skipSimulationboolean?falseSkip Solard's explicit simulation step.
options.skipPreflightboolean?—Sender preflight preference.

sell

Build, simulate by default, submit, and confirm a routed sell for one wallet.

ts
sell(
  token: TokenRef,
  wallet: WalletRef,
  options?: {
    bps?: number;
    slippageBps?: number;
    via?: SenderId;
    skipSimulation?: boolean;
    skipPreflight?: boolean;
  },
): Promise<SendReceipt>
  • The method is an execution method. bps selects the fraction of token balance sold; sender defaults to rpc inside the core method when omitted.
OptionTypeDefaultMeaning
tokenTokenRef—Registered token to sell.
walletWalletRef—Stored signing wallet.
options.bpsnumber?—Balance fraction in basis points.
options.slippageBpsnumber?—Optional slippage override.
options.viaSenderId?rpcSender lane.
options.skipSimulationboolean?falseSkip explicit Solard simulation.
options.skipPreflightboolean?—Sender preflight preference.