Search
⌃K

Write Operations

Write Operations represent actions that are capable of modifying the state of an EXM Function. These actions are processed through EXM and saved permanently in Arweave.

Usage

Let's take a look at the following EXM Function source code which we will assume it is being used in the examples below.
// Initial state: '{ "users": []}'
export async function handle(state, action) {
state.users.push({ name: `${action.input.name}` });
return { state };
}

SDK

JS SDK
import { Exm, ContractType } from '@execution-machine/sdk';
import { readFileSync } from 'fs';
const exm = new Exm({ token: 'MY_EXM_TOKEN' });
const functionId: string = '';
const inputs = [{ name: 'Clark Kent' }];
await exm.functions.write(functionId, inputs);
// {
// status: "SUCCESS",
// data: {
// pseudoId: string;
// execution: {
// state: T,
// . result: any,
// validity: Record<string, boolean>
// }
// }
// }
  • data.psuedoId refers to a pseudo id generated during the operation. This is not he final id as it could take a few seconds for EXM to reach finality.
  • data.execution.state refers to the optimistic evaluation of the single operation or batch of operations sent during the write action.
  • data.execution.result refers to value of the property result if present in the object that is returned by the function.
  • data.execution.validity refers to an object with boolean values with the single or multiple pseudo ids inserted. true refers to a successful interaction, false refers to an interaction that fail at an executor level.

Considerations

Write Operations returned the optimistic version of the state. Finality can take from milliseconds to seconds in order for it to be available for read operations.
Optimistic results returned by write operations are constructed from the latest final version available.

CLI

$ exm function:write 1OLypVtx3fIh-zq6iAihS0I1HBMwDp-fm_3kuGLDOTY --input '{ "name": "Clark Kent" }' --tags tag1="Some Tag Value" --token "MY_EXM_TOKEN"
For more information about deployments with exm , refer to:
$ exm function:write --help

REST Api

post
https://api.exm.dev
/api/transactions

State Result

Whether you used the SDK, CLI or the REST Api. The state result that will be given from the examples above is:
{
"users": [{ name: 'Clark Kent'}]
}

Limits

  • Batch transactions can only hold up to 499 write operations.
  • Input per transaction must be smaller than 512kb.
  • Total size of tags must be smaller than 212kb.
  • Total size of a bulk call must be smaller than 250mb.