Static Methods

Keep in mind the following points which are applicable for each create-account function:

  1. It buys ram for 8192 bytes

  2. It executes blockchain create-account transaction

  3. It sets the executive authority to active

create (name, privateKey, ?accountCreator)

Creates a fresh new account for a given name and private key

Keep in mind that this name may already exists on the network

Defaults/Optionals:

  • accountCreator - Default Account

const eoslime = require('eoslime').init();
const name = "Account name";
const privateKey = "Account private key";
const account2 = await eoslime.Account.create(name, privateKey);

createFromName (name, ?accountCreator)

Creates a fresh new account for a given name

Keep in mind that this name may already exists on the network

Defaults/Optionals:

  • accountCreator - Default Account

const eoslime = require('eoslime').init();
const account2 = await eoslime.Account.createFromName('name');

createRandom (?accountCreator)

Creates new random account

Defaults/Optionals:

  • accountCreator - Default Account

const eoslime = require('eoslime').init();
const account2 = await eoslime.Account.createRandom();

createRandoms (accountsCount, ?accountCreator)

Creates new random accounts

Defaults/Optionals:

  • accountCreator - Default Account

const eoslime = require('eoslime').init();
const accountsCount = 2;
const accounts = await eoslime.Account.createRandoms(accountsCount);

createEncrypted (password, ?accountCreator)

Create a new random account and encrypt it. Created account's data is encrypted and a cipherText is derived by encrypting privateKey::dataHash

// Account data for encrypting
{
name: account.name,
network: account.provider.network,
privateKey: account.privateKey
}

Defaults/Optionals:

  • accountCreator - Default Account

const eoslime = require('eoslime').init();
const password = 'secret password';
let encryptedJSONAccount = await eoslime.Account.createEncrypted(password);
/*
Encrypted JSON account => {
"name": "random generated",
"network": {
"name": 'name',
"url": 'url',
"chainId": 'chainId'
},
"ciphertext": "encrypted private key + dataHash"
}
*/

fromEncrypted (encryptedAccount, password)

Decrypt an encrypted account. Decrypts cipherText and gets it's parts (privateKey and dataHash). The PrivateKey is merged with the other encryptedAccount properties into an object which after the merging is hashed. This hash is validated against the dataHash for correctness.

const eoslime = require('eoslime').init();
const password = 'secret password';
let encryptedJSONAccount = await eoslime.Account.createEncrypted(password);
let decryptedAccount = eoslime.Account.fromEncrypted(encryptedJSONAccount, password);