const SRC = `export async function handle(state, action) {
const input = action.input;
if (input.function === "save") {
const { username, bio } = input;
ContractAssert(username.trim().length, "ERROR_INVALID_INPUT");
ContractAssert(typeof username === "string" && typeof bio === "string");
state.logs.push ({ username, bio });
return { state }
}
}`;
const INIT_STATE = '{"logs": []}';
const id = await mem.deploy(SRC, INIT_STATE);
Fork a function to mainnet or testnet
While the SDK should be initialized for mainnet using this method, the fork functionality allows forking mainnet deployed function to either mainnet or carbon testnet:
It is possible to assign a memorable name to a function ID using the (e.g., ans.mem instead of Tih...I5M). These .mem names are resolvable with the MEM SDK the same way you would pass a function ID:
The MEM SDK is an OSS licensed under the MIT license, check out the code's repository .