Skip to content

decentldotland/mem-testnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@decentldotland/mem-testnet

MEM functions simulation testnet

⚠️ We recommend using the MEM Carbon Testnet for a smoother, production-like developer experience when testing MEM functions.

Build & Run

git pull https://github.com/decentldotland/mem-testnet.git

npm install && npm run build && npm run start

Interact With The Testnet

async function testFunction() {
  try {
    const TESTNET_ENDPOINT = `https://mem-testnet-bfdc8ff3530f.herokuapp.com/`;
    const sc = `
    /**
 *
 * @param state is the current state your application holds
 * @param action is an object containing { input, caller } . Most of the times you will only use \`action.input\` which contains the input passed as a write operation
 * @returns {Promise<{ users: Array<{ username: string}> }>}
 */
export async function handle(state, action) {
    const { username } = action.input;
    state.users.push({ username });
    return { state, result: 'Hello MEM' };
}
    `;

    const input = '{"username": "darwin"}';
    const initState = '{"users": []}';
    const options = {
      contractType: 0,
      initState: initState,
      input: input,
      contractSrc: sc,
    };
    const result = await axios.post(TESTNET_ENDPOINT, options);
    console.log(result);
  } catch (error) {
    console.log(error);
  }
}

License

This project is licensed under the MIT License