MEM functions simulation testnet
git pull https://github.com/decentldotland/mem-testnet.git
npm install && npm run build && npm run start
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);
}
}
This project is licensed under the MIT License