@metaworklabs/macha-dev-sdk
v1.1.27
Published
Single SDK to integrate actions and content from multiple protocols
Downloads
106
Readme
Macha SDK
This SDK can be used to connect and access data from multiple protocols without separatly integrating each one of them.
Introduction
Macha dev sdk can be used for interacting with multiple protocols to access data or perform actions on them without individually integrating them in your application.
This allows developers to have the flexibility to perform inter-protocol operations i.e. having different source and triggers on either same or multiple protocols.
Under the hood the SDK uses
- Typescript
- ethers.js
- Graph and GraphQL
Getting Started
Installing Packages
To get started with using Macha SDK, you can install it with npm or yarn
npm install @metaworklabs/macha-dev-sdk
yarn add @metaworklabs/macha-dev-sdk
Usage
Initializing
- clientId - address of the client of whose metas you need to access
- signer - wallet signer object
- metas - list of all enabled metas owned by the clientId
import { Macha, Meta } from '@metaworklabs/macha-dev-sdk/lib';
import {ethers} from "ethers";
const signer: ethers.Signer = signer; // getting from your wallet
const client = new Macha({owner:clientId , signer: signer});
// get enabled metas from the Client.
const metas = client.client?.metasEnabled?.data;
Executing
// executing meta origins
const meta = new Meta(metaId);
const response = await meta.fetchMetaOrigin(requestParams, originIndex);
// trigger
const responseTrigger = await meta.triggerMeta(requestParams, triggerIndex);
Platform Supported
- React.Js, Next.Js, React Native
Input schema for Meta Creation
{
id: "",
name: "Mint Kudos",
description: "Returns a list of wallet token objects for the specified address.",
image: "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
clientId: "0x4eff290c1a734411b39aaa96eabe1e25f0e223ae",
triggers: {
"1": {
id: "1",
slug: "qwertyuiop123",
name: "sample_trigger_1",
description: "This is a sample trigger 1",
requestType: "CONTRACT",
requestMethod: "updatePing",
requestEndpoint:
"0x66290530D75bB75cbD92e7cF07ef76B8D367f328",
requestParams: {
title: "Trigger_params_1",
type: "object",
properties: {
id: {
type: "string",
},
name: {
type: "string",
},
age: {
type: "integer",
minimum: 0,
},
},
additionalProperties: false,
required: ["id", "name"],
},
requestSchema: [], // Contract -> ABI, Graph -> Query, REST -> URL
requestSchemaCid: "",
responseSuccess: {},
responseError: {},
},
"2": {
id: "2",
slug: "iyuriuw",
name: "sample_trigger_2",
description: "This is a sample trigger 2",
requestType: "CONTRACT",
requestMethod: "accountDetails",
requestEndpoint:
"0x66290530D75bB75cbD92e7cF07ef76B8D367f328",
requestParams: {
title: "Trigger_params",
type: "object",
properties: {
firstName: {
type: "string",
},
lastName: {
type: "string",
},
age: {
type: "integer",
minimum: 0,
},
},
additionalProperties: false,
required: ["firstName", "lastName"],
},
requestSchema: [],
requestSchemaCid: "",
responseSuccess: {},
responseError: {},
},
},
origin: {
requestType: "REST",
requestMethod: "GET",
requestEndpoint: "https://api.mintkudos.xyz/v1/wallets/{{address}}/tokens",
requestParams: {
address: "string",
},
requestSchema:"",
requestSchemaCid: "",
requestHeaders: {},
},
source: {
network: "hyperspace",
chainId: "3141",
contractAddress: "0xAC6E98027A0bDE7d8c2EAe94427593dc25fc63F4",
},
prevIpfsCid: "",
mapping: {},
}