Skip to main content

Sign-Up

The signUp method is used to register a new user with zkDatabase. During sign-up, the user must provide an email address, this email will be used for authentication purposes on the GUI management tool.

Definition

await zkdb.auth.signUp(email: string): Promise<TUserSignUpResponse>;

Parameters

  • email (String): The user's email address.

Returns

  • A promise that resolves when the user is successfully registered.
type TUserSignUpResponse = {
userName: string;
email: string;
publicKey: string;
activated: boolean;
userData: Record<string, any> | null;
createdAt: Date;
updatedAt: Date;
};

Example

import { ZkDatabase } from 'zkdb';

const zkdb = await ZkDatabase.connect({
userName: "chiro-user",
privateKey: "EKFTciRxyxshZjimay9sktsn7v5PvmC5zPq7q4JnitHUytxUVnFP",
environment: "node",
// This URL is for test environment
url: "https://api.zkdatabase.org/graphql",
});

if (!(await zkdb.auth.isUserExist("chiro-user"))) {
await zkdb.auth.signUp("[email protected]");
}

In this example, the signUp method registers a new user with the username chiro-user and email [email protected]. The signer must be setup beforehand to authenticate the sign-up process see Setup your credentials.