Update README.md

in #utopian-io7 years ago (edited)

Details

Added examples for 10 methods.

Components

Examples for methods:

  • getKeyReferences
  • getAccounts
  • lookupAccountNames
  • lookupAccounts
  • verify
  • getPrivateKeys
  • isWif
  • toWif
  • wifIsValid
  • wifToPublic

Diff

Example:

var publicKeys = ['STM6...', 'STM5...'];
steem.api.getKeyReferences(publicKeys, function(err, result) {
//console.log(err, result);
if (!err) {
 result.forEach(function(item) {
   console.log('getKeyReferences', 'username: [', item[0], ']');
 });
}
else console.error(err);
});

Example:

var accounts = [ 'epexa', 'epexa2' ];
steem.api.getAccounts(accounts, function(err, result) {
//console.log(err, result);
if (!err) {
 result.forEach(function(item) {
   console.log('getAccounts', 'username: [', item.name, '] id: [', item.id, ']');
 });
}
else console.error(err);
});

Example:

var usernames = ['epexa', 'epexa2'];
steem.api.lookupAccountNames(usernames, function(err, result) {
//console.log(err, result);
if (!err) {
 result.forEach(function(item) {
   if (item) console.log('lookupAccountNames', 'username: [', item.name, '] id: [', item.id, ']');
   else console.log('lookupAccountNames', 'account not found!');
 });
}
else console.error(err);
});

Example:

var searchAccountsQuery = 'epe';
var limitResults = 10;
steem.api.lookupAccounts(searchAccountsQuery, limitResults, function(err, result) {
//console.log(err, result);
if (!err) {
 result.forEach(function(item) {
   console.log('lookupAccounts', 'username: [', item, ']');
 });
}
else console.error(err);
});

Example:

var username = 'epexa';
var password = 'P5...'; // master password
// object in which the key type public key (active, memo, owner, posting), and the value of the array in the array itself is the public key
var auths = {
posting: [['STM6...']]
};
var verifyResult = steem.auth.verify(username, password, auths);
console.log('verify', verifyResult);

Example:

var username = 'epexa';
var password = 'P5J...'; // master password
var roles = ['owner', 'active', 'posting', 'memo']; // optional parameter, if not specify, then all keys will return
var keys = steem.auth.getPrivateKeys(username, password, roles);
console.log('getPrivateKeys', keys);

Example:

var privWif = '5K...';
var resultIsWif = steem.auth.isWif(privWif);
console.log('isWif', resultIsWif);

Example:

var username = 'epexa';
var password = 'P5J...'; // master password
var role = 'posting'; // private key type, one of owner, active, posting, memo
var privateKey = steem.auth.toWif(username, password, role);
console.log('toWif', privateKey);

Example:

var privWif = '5K...'; // private key
var pubWif = 'STM6...'; // public key
var resultWifIsValid = steem.auth.wifIsValid(privWif, pubWif);
console.log('wifIsValid', resultWifIsValid);

Example:

var privWif = '5K...'; // private key
var resultWifToPublic = steem.auth.wifToPublic(privWif, pubWif);
console.log('wifToPublic', resultWifToPublic);

Links

View new README.md
Pull request



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

Your pull request is not yet merged. Only merged pull requests are accepted in Utopian.

Some suggestions for your future contributions is

  • Please try to make your title more informative.

  • Please remove your old contribution before submitting new contribution after the PR is merged so that your post is rejected due to duplicate content.

Thanks!

For questions and feedback you can contact us on Discord.

[utopian-moderator]