Skip to main content

Import

import { SmartAccountKit } from 'smart-account-kit';

Constructor

const kit = new SmartAccountKit(config: SmartAccountConfig);
See Configuration for all available options.

Sub-Manager Properties

After construction, the following sub-managers are available as properties:
PropertyTypeDescription
kit.signersSignerManagerAdd/remove signers on context rules
kit.rulesContextRuleManagerCRUD for context rules
kit.policiesPolicyManagerAttach/detach policies
kit.credentialsCredentialManagerLocal credential lifecycle
kit.multiSignersMultiSignerManagerMulti-signer transaction flows
kit.externalSignersExternalSignerManagerG-address / wallet signers
kit.indexerIndexerClient | nullContract discovery
kit.relayerRelayerClient | nullFee-sponsored submission
kit.eventsSmartAccountEventEmitterEvent subscriptions
kit.walletWalletClient | nullRaw contract client (after connect)

Wallet Lifecycle

createWallet()

Create a new smart account secured by a WebAuthn passkey.
const { contractId, credentialId } = await kit.createWallet(
  appName: string,
  userName: string,
  options?: CreateWalletOptions
);
Options:
OptionTypeDefaultDescription
autoSubmitbooleanfalseDeploy the wallet immediately
autoFundbooleanfalseFund via Friendbot (testnet only)
nativeTokenContractstring-Required when autoFund is true
const { contractId, credentialId } = await kit.createWallet('My App', 'user@example.com', {
  autoSubmit: true,
  autoFund: true,
  nativeTokenContract: 'CDLZFC3...',
});

connectWallet()

Restore a session or prompt for passkey selection.
const result = await kit.connectWallet(options?: ConnectWalletOptions);
// Returns ConnectWalletResult | null
Options:
OptionTypeDescription
promptbooleanShow passkey selection UI
freshbooleanIgnore session, always prompt
credentialIdstringConnect with a specific credential
contractIdstringConnect with a specific contract
await kit.connectWallet();                            // Silent restore
await kit.connectWallet({ prompt: true });            // Always prompt
await kit.connectWallet({ fresh: true });             // Ignore cached session
await kit.connectWallet({ credentialId: '...' });     // Specific credential
await kit.connectWallet({ contractId: 'C...' });      // Specific contract

disconnect()

Clear the session. The passkey and contract remain on-chain.
await kit.disconnect();

authenticatePasskey()

Perform passkey authentication without connecting to a wallet.
const authResult = await kit.authenticatePasskey();

Transaction Methods

signAndSubmit()

Sign auth entries for a transaction and submit it. This is the recommended path for smart-account auth flows.
const result = await kit.signAndSubmit(
  transaction: Transaction | FeeBumpTransaction,
  options?: SubmissionOptions
): Promise<TransactionResult>

executeAndSubmit()

Build a smart-account mediated contract call, sign it, and submit. Preferred for arbitrary contract calls.
const result = await kit.executeAndSubmit(
  target: string,
  targetFn: string,
  targetArgs: xdr.ScVal[],
  options?: SubmissionOptions
): Promise<TransactionResult>
const result = await kit.executeAndSubmit('CTARGET...', 'set_config', [owner, threshold]);

execute()

Build the assembled transaction for a smart-account mediated call without submitting.
const tx = await kit.execute(
  target: string,
  targetFn: string,
  targetArgs: xdr.ScVal[]
): Promise<AssembledTransaction>

sign()

Sign auth entries on a transaction. Use signAndSubmit() unless you need to inspect the signed entries.
const signedTx = await kit.sign(transaction, options?: SubmissionOptions);

signAuthEntry()

Sign a single auth entry.
const signedEntry = await kit.signAuthEntry(authEntry, options?);

transfer()

Transfer tokens from the connected smart account.
const result = await kit.transfer(
  tokenContract: string,
  recipient: string,
  amount: number | bigint | string,
  options?: { forceMethod?: 'rpc' | 'relayer' }
): Promise<TransactionResult>
// Transfer via relayer (if configured) or RPC
await kit.transfer('CTOKEN...', 'GRECIPIENT...', 100);

// Force RPC even if relayer is configured
await kit.transfer('CTOKEN...', 'GRECIPIENT...', 100, { forceMethod: 'rpc' });

Contract Discovery

discoverContractsByCredential()

Find smart account contracts associated with a credential ID (via indexer).
const contracts = await kit.discoverContractsByCredential(credentialId: string);

discoverContractsByAddress()

Find smart account contracts associated with a Stellar address (via indexer).
const contracts = await kit.discoverContractsByAddress(address: string);

getContractDetailsFromIndexer()

Fetch full contract details including rules, signers, and policies.
const details = await kit.getContractDetailsFromIndexer(contractId: string);

Utility Methods

fundWallet()

Fund the connected wallet via Friendbot (testnet only).
await kit.fundWallet(nativeTokenContract: string);

convertPolicyParams()

Convert policy parameter objects to ScVal for on-chain use.
const scVal = kit.convertPolicyParams(params: PolicyConfig);

buildPoliciesScVal()

Build a policies ScVal array for context rule creation.
const policiesScVal = kit.buildPoliciesScVal(policies: PolicyConfig[]);

Raw Wallet Escape Hatch

The generated contract client is accessible as kit.wallet after connecting. Use it directly for contract methods the SDK intentionally does not wrap: upgrade, batch_add_signer, get_signer_id, get_policy_id, and get_context_rules_count.
// Only available after kit.connectWallet()
const count = await kit.wallet?.get_context_rules_count();
const signerId = await kit.wallet?.get_signer_id({ signer });
Rule of thumb: if the SDK adds orchestration, session handling, signer resolution, or submission logic, use the wrapper. If it’s a thin contract call, use kit.wallet directly.