Deploy to testnet

There are two options to deploy a function to the MEM Carbon Testnet -- with the CLI or with a custom script.

Option A: Testnet deployment with the CLI

Install the MEM CLI

npm i -g mem-cli-js

Deploy a function

mem deploy --testnet --src ./function.js --init-state ./state.json

Option B: Testnet deployment with a script

import * as fs from 'fs';
import axios from 'axios';


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, body))?.data
    return function_id;
  } catch (error) {

Last updated ยฉ 2023