Account

Account

The SDK provides an Account class for creating and managing accounts on Endless network.

Due to ZKLogin and MultiSign Account design, Endless support two types of account:

  • SingleSender supports ED25519 signer authenticator

  • MultiAuthKeyAccount supports one private key holding multi signers authenticator

The Account class supports different static methods to generate and/or derive an account

  • Account.generate()

  • Account.fromPrivateKey()

  • Account.fromDerivationPath()

Generate a new account

To generate a new account (or a new key pair), the SDK provides a generate() static method on the Account class.

Account generation supports Ed25519 key schemes.

const account = Account.generate(); 

Creating an account with the SDK creates it locally, to create the account on chain we should fund it.

const transaction = await endless.fundAccount({
  signer: account
});

Derive an account from private key

The SDK supports deriving an account from a private key with fromPrivateKey() static method. This method uses a local calculation and therefore is used to derive an Account that has not had its authentication key rotated.

// to derive an account with Ed25519 key scheme
const privateKey = new Ed25519PrivateKey(privateKeyBytes);
const account = Account.fromPrivateKey({ privateKey });

Derive an account from derivation path

The SDK supports deriving an account from derivation path with fromDerivationPath() static method.

// to derive an account with mnemonic and path
const derivationPath = `m/44'/637'/0'/0'/0'`;
const mnemonicWordsStr = "salt purpose ......";

const account = Account.fromDerivationPath({
  path,
  mnemonicWordsStr,
});

Last updated