
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@decentldotland/mem-sdk
JS SDK for MEM Serverless Functions
git clone https://github.com/decentldotland/mem-sdk.git
cd mem-sdk
npm install && npm run build
dist/index.cjs.js
3.46 kB │ gzip: 1.07 kBdist/index.umd.js
3.66 kB │ gzip: 1.17 kBdist/index.es.js
4.74 kB │ gzip: 1.18 kBnpm install mem-sdk
import Mem from "mem-sdk";
const mem : Mem = new Mem({
network: "mainnet" || "testnet"
});
const { Mem } = require("mem-sdk");
const mem: Mem = new Mem({
network: "mainnet" || "testnet"
});
import { Mem } from "mem-sdk"
const mem = new Mem({
network: "mainnet" || "testnet"
});
const FUNCTION_ID = "...";
const state = await mem.read(FUNCTION_ID);
const FUNCTION_ID = "...";
const inputs = { function: "test", inputA: "valueA" };
const txid = await mem.write(FUNCTION_ID, inputs);
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);
While the SDK should be initialized for mainnet
using this method, the fork
functionality allows forking mainnet deployed function to either mainnet or carbon testnet:
const MAINNET_FUNCTION_ID = "...";
const FORK_IT_TO = "mainnet" || "testnet";
const OVERWRITE_INIT_STATE = btoa('{"new": "state"}'); // optional
const id = await mem.fork(MAINNET_FUNCTION_ID, FORK_IT_TO, OVERWRITE_INIT_STATE?);
mainnet
)const MAINNET_FUNCTION_ID = "...";
const kv = await mem.kvGet(MAINNET_FUNCTION_ID);
mainnet
)It is possible to assign a memorable name to a function ID using the function registry tool (e.g., ans.mem
instead of Tih...I5M
). These .mem
names are resolvable with the MEM SDK the same way you would pass a function ID:
await mem.read("ans.mem");
This repository is licensed under the MIT License
FAQs
JS SDK for MEM Serverless Functions
The npm package mem-sdk receives a total of 0 weekly downloads. As such, mem-sdk popularity was classified as not popular.
We found that mem-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.