Contract Example: Counter

Counter Smart Contract in JS

Source Code

export async function handle(state, action) {
  const input = action.input;

  if (input.function === "increment") {
    state.counter += 1;
    state.users.push(lambda.msg.sender);
    return { state };
  }
}

Initial State

{
  "counter": 0,
  "users": []
}

Last updated