Constructs an instance of the class with the specified parameters.
// Import the AlgorandClient
import {AlgorandClient} from "@algorandfoundation/algokit-utils";
// Import the Store class
import {Store} from "./src";
const algorand = AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
const store = new Store({
algorand,
deployer,
options: {
foo: "bar",
baz: 123,
},
})
Protected
algorandRepresents an instance of AlgorandClient, which provides mechanisms to interact with the Algorand blockchain network.
The algorand
variable can be used to perform various operations such as
querying blockchain data, submitting transactions, and interacting with Algorand smart contracts.
It acts as an interface to communicate with the Algorand network through methods exposed by the AlgorandClient.
Protected
Optional
clientExperimental: On-chain client for the Lodash application.
Protected
Readonly
deployerRepresents a smart contract wallet capable of signing transactions.
A Deployer
is critical for managing interactions with Algorand smart contracts. It
facilitates operations such as deploying and interacting with applications by ensuring
all transactions are signed appropriately. See AppDeployer
for more information
Protected
factoryExperimental: Factory for the Lodash application.
Optional
optionsAssembles and retrieves data stored in the storage boxes of an application, decodes the content, and formats it into a structured object.
Returns a Promise that resolves to an object of type T, containing the decoded and processed data from the application storage boxes.
Initializes the instance by deploying the required application and setting up necessary configurations. Throws an error if already initialized. Deploys the application using the provided factory and performs payment if the result operation requires it.
The name of the application to deploy.
A promise that resolves when the initialization process is complete.
Saves the current state to the network. This method ensures that the app is initialized and a deployer is provided before attempting to save. It synchronizes the state by mapping paths to their respective values and storing them on-chain.
Resolves when the state has been successfully saved to the network.
Throws an error if the app has not been initialized with a client or if a deployer is not provided.
// Import a custom Store instance
import {exampleStore} from "./exampleStore"
// Save the state to the network
await exampleStore.save()
Deployer can be passed as an argument to the save method
// Import a custom Store instance
import {exampleStore} from "./exampleStore"
// Define a deployer
const deployer = await algorand.account.fromMnemonic("example deployer mnemonic")
// Save the state to the network
await exampleStore.save(deployer)
A specialized
Store
class extending from @tanstack/store, designed for managing and interacting with application-level state on the Algorand blockchain.The class provides methods to deploy, initialize, save, and retrieve application state stored in Algorand application storage boxes. It leverages the AlgorandClient for blockchain interactions and a Deployer for deploying and signing transactions.
Get Started
See the Store.constructor method for more information on how to instantiate the class.