Eoslime
  • Introduction
  • Examples
  • Tutorial
  • Changelog
    • Version 2.0.0 [TypeScript]
    • Version 1.0.4
    • Version 1.0.3
    • Version 1.0.2
    • Version 1.0.1
  • Developer Documentation
    • Initialization
    • Account
      • Methods
      • Static Methods
      • Default Account
    • Multisignature Account
      • Methods
    • Providers
    • Contract
      • Deployment
      • Instantiation
      • Blockchain Contract Action Methods
    • Utils
  • CLI
    • init
      • --with-example
    • compile
      • --path
    • deploy
      • --path
      • --network
      • --deployer
    • test
      • --path
      • --network
      • --resource-report
    • shape
      • --framework
    • nodeos
      • start
        • --path
      • stop
      • logs
        • --lines
      • accounts
Powered by GitBook
On this page
  • toName(encodedName)
  • randomName()
  • nameFromPrivateKey()
  • randomPrivateKey()
  • generateKeys()

Was this helpful?

  1. Developer Documentation

Utils

eoslime.utils

toName(encodedName)

Useful when your account name is represented as uint64_t and you want to convert it to a readable string

const eoslime = require('eoslime').init();

const DONATION_ABI_PATH = './contracts/example/donation.abi';

const donationContract = eoslime.Contract.at('donation.acc');

// First donator name is 'donater.name'
// In the contract it is encoded as 5559250271203861664
const donaters = await donationContract.getDonaters();

// donaters[0].account => 5559250271203861664
const donaterName = eoslime.utils.toName(donaters[0].account);
// donaterName => 'donater.name'

randomName()

Generates a random account name for you

const eoslime = require('eoslime');
const randomName = eoslime.utils.randomName();
// randomName => 'l33fe2bf215c'

nameFromPrivateKey()

Construct an account name from a private key. The name is constructed in a custom way, it is not related to the private key in any manner.

const eoslime = require('eoslime');
const name = eoslime.utils.nameFromPrivateKey('private key');
// name => 'l33fe2bf215c'

randomPrivateKey()

Generates a random private key.

const eoslime = require('eoslime');
const privateKey = eoslime.utils.randomPrivateKey();

generateKeys()

Generates a public/private key pair

const eoslime = require('eoslime');
const keyPair = eoslime.utils.generateKeys();
/* 
    keyPair => 
        { 
            privateKey: '5KRMNhyxuyymrZ3dEy2Tsy2a794DBmNBZWoPjR9BzT15QSLomLr',
            publicKey: 'EOS54gGNru7KbXWcbpQAFbRP7ftWE3dNY5C2igrnYsTRXvvewsNni'
        }
*/
PreviousBlockchain Contract Action MethodsNextinit

Last updated 4 years ago

Was this helpful?