SDK patterns for entities, rooms and claims

Illustrative TypeScript patterns for the IXO MultiClient SDK and IXO Matrix Client SDK: create an entity, use its data room, then submit and evaluate a claim.

These snippets show the shape of the common calls in the IXO MultiClient SDK (@ixo/impactxclient-sdk) and the IXO Matrix Client SDK (@ixo/matrixclient-sdk). Adapt them to your own code. The step-by-step explanation is in Developer workflows, and exact field shapes come from the chain proto definitions.

If you want a path you can run and test from start to finish today, use the decision oracle guide. It has unit tests, a dry run against a real claim, and a preview of the decision.

Setup

npm install @ixo/impactxclient-sdk @ixo/matrixclient-sdk
import {
  ixo,
  createQueryClient,
  createSigningClient,
} from "@ixo/impactxclient-sdk";
import {
  createMatrixApiClient,
  createMatrixRoomBotClient,
  createMatrixStateBotClient,
  createMatrixClaimBotClient,
} from "@ixo/matrixclient-sdk";

// Take both from your environment. Use endpoints for the same test network.
const RPC_ENDPOINT = process.env.RPC_ENDPOINT!; // testnet: https://testnet.ixo.earth/rpc/
const MATRIX_BASE_URL = process.env.MATRIX_BASE_URL!; // testnet: https://testmx.ixo.earth

const queryClient = await createQueryClient(RPC_ENDPOINT);
const signingClient = await createSigningClient(RPC_ENDPOINT, offlineSigner);

The RPC endpoint and the Matrix homeserver must belong to the same network. The hosts for each network are listed in Networks and endpoints. On the development homeserver the bots are at /bots/room, /bots/state and /bots/claim on the same host. For another network, confirm the bot URLs with whoever operates your deployment, and set MATRIX_ROOM_BOT_URL, MATRIX_STATE_BOT_URL and MATRIX_CLAIM_BOT_URL to match.

What you supply

The snippets use these names without declaring them. Each one is yours to provide.

NameWhat it isWhere it comes from
offlineSignerA signer for your accountSee Creating signers in the SDK README
signerAddressThe ixo1… address of that signerYour signer
matrixAccessTokenYour Matrix access tokenYour Matrix login. See the authentication matrix
ucanTokenA UCAN that proves you may act on the entityA delegation from a controller of the entity
telemetryFileThe file content to uploadYour application
recipientAddressThe account that receives minted tokensYour application
collectionId, adminAddress, oracleAddress, tokenContractAddressThe claim collection, its admin account, the evaluating oracle, and your token contractThe collection and contract you created, on the same network

The identifiers in the snippets, such as did:ixo:entity:protocol123 and bafkreih..., are placeholders. Replace every one.

Digital twin: create an entity

const createEntity = async (signerAddress: string) => {
  const message = {
    typeUrl: "/ixo.entity.v1beta1.MsgCreateEntity",
    value: ixo.entity.v1beta1.MsgCreateEntity.fromPartial({
      ownerAddress: signerAddress,
      entityType: "asset",
      context: [
        ixo.iid.v1beta1.Context.fromPartial({
          key: "class",
          val: "did:ixo:entity:protocol123",
        }),
      ],
      verification: [],
      controller: [],
      service: [],
      linkedResource: [],
      accordedRight: [],
      linkedEntity: [],
      linkedClaim: [],
    }),
  };

  return signingClient.signAndBroadcast(signerAddress, [message], "auto");
};

const entities = await queryClient.ixo.entity.v1beta1.entityList();

Source an entity room (IXO Matrix)

Each domain has an encrypted Matrix room, its data room. Source it by the entity's DID with the room bot, which creates the room if needed and invites the caller.

const matrixRoomBotClient = createMatrixRoomBotClient({
  homeServerUrl: MATRIX_BASE_URL,
  botUrl: process.env.MATRIX_ROOM_BOT_URL!,
  accessToken: matrixAccessToken,
});

const sourceRoomResponse = await matrixRoomBotClient.room.v1beta1.sourceRoomAndJoin(
  "did:ixo:entity:abc...xyz",
  ucanToken,
);

const roomId = sourceRoomResponse.roomId;

The ucanToken carries the caller's capability to act on the entity. The optional accessToken is the user's Matrix client-server access token, used only for the local join and never sent to the bot server. See Matrix authentication.

Upload telemetry into the data room

const matrixApiClient = createMatrixApiClient({
  homeServerUrl: MATRIX_BASE_URL,
  accessToken: matrixAccessToken,
});

const upload = await matrixApiClient.media.v1beta1.upload(
  "telemetry-2025-04.json",
  "application/json",
  telemetryFile,
);

const mxcUri = upload.content_uri;

Read or set room state via the State Bot

Use the State Bot to attach structured profile or settings data to an entity room.

const matrixStateBotClient = createMatrixStateBotClient({
  homeServerUrl: MATRIX_BASE_URL,
  botUrl: process.env.MATRIX_STATE_BOT_URL!,
  accessToken: matrixAccessToken,
});

const stateData = await matrixStateBotClient.state.v1beta1.queryState(
  roomId,
  "impactsX",
  "profile",
  ucanToken,
);

await matrixStateBotClient.state.v1beta1.setState(
  roomId,
  "impactsX",
  "profile",
  JSON.stringify({ displayName: "Solar Farm Alpha", capacityKw: 5000 }),
  ucanToken,
);

Claim sequence: submit, evaluate, mint

The sequence for a digital MRV outcome. Each numbered step is a separate transaction. Step 3 records a decision, so run it only when you hold a real one.

const collectionId = "12";
const adminAddress = "ixo1...";
const oracleAddress = "ixo1oracle...";
const tokenContractAddress = "ixo1contract...";

// 1. Submit a claim referencing evidence stored in the data room
const submitClaimMsg = {
  typeUrl: "/ixo.claims.v1beta1.MsgSubmitClaim",
  value: ixo.claims.v1beta1.MsgSubmitClaim.fromPartial({
    creator: signerAddress,
    claimId: "bafkreih...",
    collectionId,
    adminAddress,
  }),
};

await signingClient.signAndBroadcast(signerAddress, [submitClaimMsg], "auto");

// 2. Optional Claim Bot helpers (off-chain co-ordination)
const matrixClaimBotClient = createMatrixClaimBotClient({
  homeServerUrl: MATRIX_BASE_URL,
  botUrl: process.env.MATRIX_CLAIM_BOT_URL!,
  accessToken: matrixAccessToken,
});

const claimRecord = await matrixClaimBotClient.claim.v1beta1.queryClaim(
  collectionId,
  "bafkreih...",
  ucanToken,
);

// 3. Evaluate after the Agentic Oracle has produced a verification
const evaluateMsg = {
  typeUrl: "/ixo.claims.v1beta1.MsgEvaluateClaim",
  value: ixo.claims.v1beta1.MsgEvaluateClaim.fromPartial({
    creator: signerAddress,
    claimId: "bafkreih...",
    collectionId,
    oracle: oracleAddress,
    adminAddress,
    status: 1, // 1 = approved, 2 = rejected. Set it from the decision. Never hardcode it
    reason: 0,
    verificationProof: "bafkrei-proof-cid",
    amount: [],
  }),
};

await signingClient.signAndBroadcast(signerAddress, [evaluateMsg], "auto");

// 4. Mint outcome tokens against the approved claim
const mintMsg = {
  typeUrl: "/ixo.token.v1beta1.MsgMintToken",
  value: ixo.token.v1beta1.MsgMintToken.fromPartial({
    minter: signerAddress,
    contractAddress: tokenContractAddress,
    owner: recipientAddress,
    mintBatch: [
      ixo.token.v1beta1.MintBatch.fromPartial({
        name: "CARBON",
        index: "bafkreih...",
        amount: "3600",
        collection: "did:ixo:entity:collection456",
        tokenData: [],
      }),
    ],
  }),
};

await signingClient.signAndBroadcast(signerAddress, [mintMsg], "auto");

Where the decision comes from

Step 3 above writes a decision to the chain. It does not make one. The check that produces the decision is a separate service.

If you use a decision oracle built with @ixo/decision-oracle, you do not write MsgEvaluateClaim yourself. The oracle gets the decision from the decision engine, and records it on chain with the engine's signed receipt as the verificationProof. See Decision oracle.

Write MsgEvaluateClaim by hand only when you run your own evaluation service. In that case:

  • Set status from the result of your evaluation. The protocol's values are 0 pending, 1 approved, 2 rejected, 4 invalidated and 5 flagged. The chain no longer accepts 3 (disputed) on a new evaluation: a dispute is its own record. See How claim disputes work on chain.
  • Handle a rejection and an undecided claim as carefully as an approval. A claim you cannot decide can be flagged, which fires no payment and can be re-evaluated later.
  • Your account needs an EvaluateClaimAuthorization on the collection, or the chain refuses the message. See Custom authorisations for IXO Claims.

Next steps