Oh so you are finally hereStackr exposes a Micro-Rollup Api that takes in all the things we built previously and wrap it around an applicationThis is how it looks like
Copy
const counterFsm = new StateMachine({ state: new CounterRollup(genesisState.state), stf: counterSTF,});const actionSchemaType = { type: "String" };const actionInput = new ActionSchema("update-counter", actionSchemaType);const buildStrategy = new FIFOStrategy();const { actions, ...otherUtilities } = await MicroRollup({ // the config config: stackrConfig, // the state machine that has an STF attached useState: counterFsm, // The user/entity input to the micro-rollup useAction: actionInput, // the sequencer that will order actions useBuilder: { strategy: buildStrategy, autorun: true }, // Syncer will send the actions to the Vulcan useSyncer: { autorun: true },});
// any user's/entities walletconst wallet = ethers.Wallet.createRandom();// the action that we want to sendconst data = { type: "increment",};// sign the actionconst signature = await wallet.signTypedData( stackrConfig.domain, // we use the same actionInput schema to get EIP-712 types actionInput.EIP712TypedData.types, data);// create a payloadconst payload = JSON.stringify({ msgSender: wallet.address, signature: sign, payload: data,});
The payload is a JSON string that contains the following, and MUST conform to the following schema
Copy
{ msgSender: string, // the user/entity's address signature: string, // the signature of the action payload: any, // the action data}
We use the actions object that we got from the Micro-Rollup and get the schema from it.
Use the same identifier that was used to create the actionInput
The Micro-Rollup will order the actions and build blocks based on the strategy that was passed to it and the config which governs the block size and other parameters