Socket
Socket
Sign inDemoInstall

mem-sdk

Package Overview
Dependencies
245
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mem-sdk

JS SDK for MEM Serverless Functions


Version published
Weekly downloads
8
decreased by-33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@decentldotland/mem-sdk

JS SDK for MEM Serverless Functions

Build size

dist/index.cjs.js 1.52 kB │ gzip: 0.69 kB
dist/index.umd.js 1.72 kB │ gzip: 0.80 kB
dist/index.es.js 1.95 kB │ gzip: 0.74 kB

Build Locally

git clone https://github.com/decentldotland/mem-sdk.git

cd mem-sdk

npm install && npm run build

Install

npm install mem-sdk

Usage Guide

Import MEM SDK

React, and other frameworks (also check out React Version):

import Mem from "mem-sdk";
const mem : Mem = new Mem();

Node:

const { Mem } = require("mem-sdk");
const mem: Mem = new Mem();

Retrieve a function state

const FUNCTION_ID = "...";
const state = await mem.read(FUNCTION_ID);

Send an interaction (only works on server-side)

const FUNCTION_ID = "...";
const inputs = { function: "test", inputA: "valueA" };

const txid = await mem.write(FUNCTION_ID, inputs);

Deploy a function

const SRC = `export async function handle(state, action) {
  const input = action.input;


if (input.function === "save") {
    const { username, bio } = input;

    ContractAssert(username.trim().length, "ERROR_INVALID_INPUT");
    ContractAssert(typeof username === "string" && typeof bio === "string");
    state.logs.push ({ username, bio });
    return { state }
  }
}`;

const INIT_STATE = '{"logs": []}';

const id = await mem.deploy(SRC, INIT_STATE);

License

This repositoy is licensed under the MIT License

Keywords

FAQs

Last updated on 21 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc