@wuwei-labs/srsly
Version:
[](https://www.npmjs.com/package/ts-sdk-example)
73 lines • 2.29 kB
TypeScript
import { Address, TransactionSigner } from '@solana/kit';
import { CreateContractInstruction, getCreateContractInstructionAsync } from '../codama';
/**
* Simplified parameters for creating a rental contract
*/
export interface CreateContractParams {
/**
* The owner wallet that will sign the transaction
*/
owner: TransactionSigner<string>;
/**
* The fleet account address to be rented out
*/
fleet: Address<string>;
/**
* The owner's profile account address
*/
ownerProfile: Address<string>;
/**
* The rental rate in ATLAS tokens
*/
rate: number | bigint;
/**
* The minimum rental duration in seconds
*/
durationMin: number | bigint;
/**
* The maximum rental duration in seconds
*/
durationMax: number | bigint;
/**
* The payment frequency (e.g., "daily", "weekly", "monthly")
*/
paymentsFreq: string;
/**
* The owner key index
* Typically 0 unless the owner has multiple authorized keys
*/
ownerKeyIndex?: number;
/**
* The game ID account address
* Defaults to 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr' if not provided
*/
gameId?: Address<string>;
}
/**
* Asynchronously creates an instruction to create a rental contract with minimal required parameters.
* Derives ownerTokenAccount, contract, and rentalAuthority automatically if not provided.
*
* @example
* ```typescript
* // Create the instruction with minimal parameters
* const ix = await createContract({
* owner: wallet,
* fleet: fleetAddress,
* ownerProfile: profileAddress,
* rate: 100, // 100 ATLAS per second
* durationMin: 3600, // 1 hour in seconds
* durationMax: 604800, // 1 week in seconds
* paymentsFreq: "daily"
* });
*
* // Add to transaction and sign
* const tx = new Transaction().add(ix);
* await sendAndConfirmTransaction(connection, tx, [wallet]);
* ```
*
* @param params The simplified parameters for creating a rental contract
* @returns A promise that resolves to the instruction to create a contract
*/
export declare function createContract(params: CreateContractParams): Promise<CreateContractInstruction>;
export { getCreateContractInstructionAsync };
//# sourceMappingURL=create.d.ts.map