MEM Carbon is a testnet network with temporary state storage
git pull https://github.com/decentldotland/mem-carbon-testnet.git
npm install && npm run start
To keep your application data private, it's recommended to operate a local testnet instance. This will also enhance scalability and testing speed.
Nevertheless, the MEM team provides a publicly accessible endpoint. It's crucial to note that the testnet data is strictly temporary and is purged within a 1-2 day timeframe:
- Base endpoint: https://mem-testnet.xyz
- Akash hosted endpoint: http://ni8amicr1pfejdvrbav9r9grh8.ingress.d3akash.cloud/
POST /deploy
import * as fs from 'fs';
import axios from 'axios';
const TESTNET_ENDPOINT = "https://mem-testnet.xyz/deploy";
async function deploy() {
try {
const sourceCode = fs.readFileSync("./func.js", { encoding: "utf8" }); // the src code of the function
const initState = fs.readFileSync("./state.json", { encoding: "utf8" }); // the JSON initial function state
const body = {
src: sourceCode,
state: initState,
};
const function_id = (await axios.post(TESTNET_ENDPOINT, body))?.data
?.function_id;
console.log(function_id);
return function_id;
} catch (error) {
console.log(error);
}
}
POST /write
import axios from 'axios';
const TESTNET_ENDPOINT = "https://mem-testnet.xyz/write";
async function write() {
try {
const input = '{"function": "something"}'; // example: '{"function": "increment"}'
const function_id = "your_function_id";
const body = {
input,
function_id,
};
const result = (await axios.post(TESTNET_ENDPOINT, body))?.data;
console.log(result);
return result;
} catch (error) {
console.log(error);
}
}
GET /state/:function_id
GET /data/function/:function_id
GET /functions
You can use existing testing code snippets from this repository as follow:
npm run test-deploy
Grab the new function id, update the ./tests/write.js
file constant value of FUNCTION_ID
, then run the following command
npm run test-write
This repository is licensed under the MIT License