Roboqo Studio
  • Roboqo Studio
  • OVERVIEW
    • Quickstart
    • Fees and Tokens
  • Basics
    • Roboqo Scripts
    • Transactions
    • UI Elements
    • Helper Functions
  • Global Objects
    • Solana Object
    • Positions Object
    • Jito Object
    • Raydium Object
    • Jupiter Object
    • Pumpfun Object
    • Rugcheck Object
    • Warp Object
    • Memes Object
    • Script / CLI
    • Storage Object
  • Instances
    • Solana Transaction
    • Solana Bundle
    • Jito Bundle
    • Solana Position
    • Solana Aggregate Position
Powered by GitBook
On this page
  • Storage Object Documentation
  • Description
  • Methods
  • Example Usage
  1. Global Objects

Storage Object

Storage Object Documentation

Description

The Storage object provides an in-memory key-value storage system that synchronizes with a remote service using the Roboqo RPC interface. It supports both local and session storage types and provides methods to manipulate stored data efficiently. You can access storage via localStorage and sessionStorage global objects.

Methods

setItem

Description

Stores a value associated with a key and synchronizes it with the remote storage.

Signature

setItem(key: string, value: any): void

Parameters

  • key (string): The key under which the value is stored.

  • value (any): The value to store.

Example Usage

localStorage.setItem("username", "JohnDoe");

getItem

Description

Retrieves a stored value by its key.

Signature

getItem(key: string): any

Parameters

  • key (string): The key to retrieve the stored value.

Returns

  • T | null: The stored value or null if the key does not exist.

Example Usage

const username = localStorage.getItem("username");
console.log(username); // Output: "JohnDoe"

removeItem

Description

Removes a value from storage and synchronizes the removal with the remote storage.

Signature

removeItem(key: string): void

Parameters

  • key (string): The key to remove.

Example Usage

localStorage.removeItem("username");

clear

Description

Clears all stored data and synchronizes the removal with the remote storage.

Signature

clear(): void

Example Usage

storage.clear();

keys

Description

Retrieves an array of all stored keys.

Signature

keys(): string[]

Returns

  • string[]: An array of stored keys.

Example Usage

const storedKeys = localStorage.keys();
console.log(storedKeys);

toJSON

Description

Converts the stored data into a JSON object.

Signature

toJSON(): Record<string, any>

Returns

  • Record<string, any>: An object representation of the stored data.

Example Usage

const jsonData = localStorage.toJSON();
console.log(jsonData);

Example Usage

localStorage.setItem("username", "Alice");
console.log(localStorage.getItem("username")); // Output: "Alice"
localStorage.removeItem("username");
localStorage.clear();
PreviousScript / CLINextSolana Transaction

Last updated 4 months ago