@wuwei-labs/srsly
Version:
TypeScript SDK for SRSLY
57 lines • 2.29 kB
TypeScript
/**
* @purpose Simplified createContractThread instruction wrapper
*
* Thin convenience wrapper around Codama-generated createContractThread instruction.
* Creates a per-contract automation thread with fiber-based dispatch.
*/
import { type Address } from '@solana/kit';
import { type SdkConfig } from '../utils/config';
import { type UniversalSigner } from '../utils/signer';
import { prepareInstructions } from '../utils/instructions';
import { type ScheduleParam } from '../params/schedule';
import { type SolParam } from '../params/sol';
/**
* Parameters for creating a contract automation thread
*/
export interface CreateContractThreadParams {
/**
* Contract owner (must be the contract's owner)
* Accepts string address, web3.js Keypair, or @solana/kit signer
*/
owner: UniversalSigner;
/** Contract address to create thread for */
contract: Address | string;
/**
* Additional SOL preload for thread execution fees.
* Added on top of the 0.04 SOL base minimum (3 fibers + thread rent).
* When omitted, the SDK preloads enough lamports to cover ~1 year of
* `@daily` cron ticks.
* Accepts a plain number / bigint (lamports), `{ sol: number }`, or
* `{ lamports: number | bigint }`.
* @example { sol: 0.1 } // 0.1 SOL extra
* @example { lamports: 50_000_000 }
* @default
* ```ts
* { sol: 0.00219 } // ~1 year of `@daily` triggers
* ```
*/
lamports?: SolParam;
/** Payment processing frequency (cron expression or named schedule) */
paymentsFreq: ScheduleParam;
/**
* Sets compute units to allocate for the transaction.
* @example 400000
*/
computeUnits?: number;
}
/**
* Set up the per-contract automation thread that processes payments and
* lifecycle ticks. Thread starts paused; the rental_close and
* rental_activate fibers spin up lazily on first use.
*
* @param params - Thread creation parameters
* @param config - Optional SDK configuration overrides
* @returns Kit instruction (or web3.js if PublicKey in config)
*/
export declare function createContractThread(params: CreateContractThreadParams, config?: Partial<SdkConfig>): Promise<ReturnType<typeof prepareInstructions>>;
//# sourceMappingURL=createContractThread.d.ts.map