Namespace Wrapper Methods
Environment Variables
Environment variables are already pre-configured by the @_koii/namespace-wrapper
package. You can directly import and use them in your tasks without additional setup. For detailed examples, refer to the Environment Variables Usage documentation.
Database Operations
Method | Description |
---|---|
getDb(): Promise<void> | get the KOIIDB |
storeSet(key: string, value: string): Promise<void> | Stores a value in the persistent storage |
storeGet(key: string): Promise<string | null> | Retrieves a value from the persistent storage |
File System Operations
Method | Description |
---|---|
fs(method: string, path: string, ...args: any[]): Promise<any> | Executes file system operations in a standardized way |
fsStaking(method: string, path: string, ...args: any[]): Promise<any> | A decentralized staking platform enabling secure token locking for rewards. |
fsWriteStream(imagepath: string): Promise<WriteStream | void> | Creates a write stream for file operations |
fsReadStream(imagepath: string): Promise<Buffer | void> | Creates a read stream for file operations |
Blockchain/Transaction Operations
Task Status
Method | Description |
---|---|
getTaskState(options: TaskStateOptions): Promise<TaskState | null> | Retrieves the current state of the task |
getTaskStateById(taskId: string, task_type: TaskType, options: TaskStateOptions): Promise<TaskState | null> | Retrieves task state for a specific task ID and the task type |
getTaskNodeVersion(): Promise<string> | Gets the task node version |
getTaskSubmissionInfo(round: number): Promise<TaskSubmissionState | null> | Retrieves submission information for the task |
getTaskDistributionInfo(round: number): Promise<TaskDistributionInfo | null> | Gets distribution information for the task |
Network and Task Handling Methods
Method | Description |
---|---|
getNodes(url: string) | Retrieves information about network nodes |
getRpcUrl(): Promise<string | void> | Gets the current RPC URL for the Koii network |
getTaskDBPath(): Promise<string> | Gets the path to the task's NeDB database |
getBasePath(): Promise<string> | Gets the base path to the task folder for performing file operations |
getRound(): Promise<number> | Gets the current round number |
getSubmitterAccount(): Promise<Keypair | null> | Gets the submitter's account Keypair |
getMainAccountPubkey(): Promise<string | null> | Gets the main account's public key |
logger(level: LogLevel, message: string, action: string): Promise<boolean> | Logs messages based on specified log level (log, warn, error). |
getSlot(): Promise<number> | Gets the current slot number |
getAverageSlotTime(): Promise<number> | Gets average slot time for the network |