genlayer
Version:
GenLayer Command Line Tool
20 lines (15 loc) • 741 B
JavaScript
import { createClient, createAccount as createGenLayerAccount, generatePrivateKey } from "genlayer-js";
import { simulator } from "genlayer-js/chains";
const accountPrivateKey = localStorage.getItem("accountPrivateKey")
? localStorage.getItem("accountPrivateKey")
: null;
export const account = accountPrivateKey ? createGenLayerAccount(accountPrivateKey) : null;
export const createAccount = () => {
const newAccountPrivateKey = generatePrivateKey();
localStorage.setItem("accountPrivateKey", newAccountPrivateKey);
return createGenLayerAccount(newAccountPrivateKey);
};
export const removeAccount = () => {
localStorage.removeItem("accountPrivateKey");
};
export const client = createClient({ chain: simulator, account });