State Variable
Stackr allows rollupors to define their own custom state almost completely unrestricted in terms of what they can do with it This is done by defining aStateVariable and providing relevant types.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Defining Custom State
StateVariable and providing relevant types.
export type StateVariable = <YOUR_STATE_OBJECT>;
export type StateVariable = boolean;
export type StateVariable = number;
export type StateVariable = {
address: string;
balance: number;
nonce: number;
}[];
export type StateVariable = {
orders: {
id: string;
maker: string;
taker: string;
makerAmount: number;
takerAmount: number;
filled: number;
}[];
trades: {
id: string;
maker: string;
taker: string;
makerAmount: number;
takerAmount: number;
filled: number;
}[];
};
export type totalRollupSDKsThatAllowYouToBuildMicroRollups = 1;
interface StateTransport {
currentCount: StateVariable;
}
import MerkleTree from "merkletreejs";
class MerkleTreeTransport {
public merkleTree: MerkleTree;
public leaves: Accounts[];
constructor(leaves: Accounts[]) {
this.merkleTree = this.createTree(leaves);
this.leaves = leaves;
}
createTree(leaves: Accounts[]) {
const hashedLeaves = leaves.map((leaf: Accounts) => {
return ethers.solidityPackedKeccak256(
["address", "uint"],
[leaf.address, leaf.balance]
);
});
return new MerkleTree(hashedLeaves);
}
}