MEM
WebsiteLabsGuides
  • โš—๏ธMolecular Execution Machine
  • ๐Ÿ‘‹Introduction
    • What is MEM?
    • MEM features
    • MEM vs alternatives
    • Technical architecture
    • Use-case examples
  • โšกQuickstart
    • Quickstart guide
  • ๐Ÿ“–MEM Specifications
    • Function syntax
    • Function specs
    • Transaction specs
    • Supported languages
    • About MIPs
  • โš›๏ธMolecules
    • Overview
    • Multichain authentication
    • Using APIs
    • API reference
  • ๐ŸงชMEM IDE
    • Overview
    • Function ABI
  • โš’๏ธMEM Carbon Testnet
    • Overview
    • Deploy to testnet
    • Interact with testnet functions
  • โš™๏ธMEM SDK
    • SDK Usage
  • ๐Ÿ–ฅ๏ธMEM CLI
    • Function deployment
    • Function interaction
  • ๐Ÿ—๏ธMEM API
    • Overview
    • Write operations
    • Read operations
  • โš›๏ธ3EM-MEM
    • Overview
    • EXM API
    • Key-Value Storage (KVS)
  • ๐ŸงฉExamples
    • Pastebin clone
    • Query onchain data
Powered by GitBook

mem.tech ยฉ 2023

On this page
  • Option A: Testnet deployment with the CLI
  • Option B: Testnet deployment with a script
  1. MEM Carbon Testnet

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';

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);
  }
}
PreviousOverviewNextInteract with testnet functions

Last updated 1 year ago

โš’๏ธ