Skip to content

Commit 475002a

Browse files
authored
docs: 📝 update docs
1 parent b7a1165 commit 475002a

File tree

1 file changed

+58
-21
lines changed

1 file changed

+58
-21
lines changed

docs/index.md

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,74 @@
1-
## Welcome to GitHub Pages
1+
# Eosio name to uint64
22

3-
You can use the [editor on GitHub](https://github.com/manh-vv/eosjs-name/edit/master/docs/index.md) to maintain and preview the content for your website in Markdown files.
3+
[![NPM](https://img.shields.io/npm/v/eosjs-account-name.svg)](https://www.npmjs.org/package/eosjs-account-name)
4+
[![Build Status](https://travis-ci.org/manh-vv/eosjs-name.svg?branch=master)](https://travis-ci.org/manh-vv/eosjs-name)
5+
[![codecov](https://codecov.io/gh/manh-vv/eosjs-name/branch/master/graph/badge.svg?token=WLVN5CZT6Q)](https://codecov.io/gh/manh-vv/eosjs-name)
46

5-
Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files.
7+
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/manh-vv/eosjs-name)
68

7-
### Markdown
9+
```sh
10+
npm i eosjs-account-name
11+
```
12+
13+
```sh
14+
yarn add eosjs-account-name
15+
```
16+
17+
## From name to uint64
18+
19+
Here is [how eosio account name is computed to uint64](https://github.com/EOSIO/eos/blob/master/libraries/chain/include/eosio/chain/name.hpp#L21).
20+
21+
```text
22+
"eosio",
23+
"eosio.msig",
24+
"eosio.token",
25+
26+
---- 6138663577826885632
27+
---- 6138663587900751872
28+
---- 6138663591592764928
29+
```
830

9-
Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for
31+
## From uint64 to name
1032

11-
```markdown
12-
Syntax highlighted code block
33+
Source https://github.com/EOSIO/eos/blob/master/libraries/chain/name.cpp#L19
1334

14-
# Header 1
15-
## Header 2
16-
### Header 3
35+
## Example
1736

18-
- Bulleted
19-
- List
37+
Try on run-kit https://npm.runkit.com/eosjs-account-name
2038

21-
1. Numbered
22-
2. List
39+
```javascript
40+
const eosjsAccountName = require('eosjs-account-name');
41+
const n = eosjsAccountName.nameToUint64('eosio');
2342

24-
**Bold** and _Italic_ and `Code` text
43+
console.log('eosio to uint64: ' + n);
2544

26-
[Link](url) and ![Image](src)
45+
console.log('uint64 to name: ' + eosjsAccountName.uint64ToName(n));
2746
```
2847

29-
For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/).
48+
### Parse symbol name
49+
50+
[symbol.test.js](./__tests__/symbol.test.js)
3051

31-
### Jekyll Themes
52+
```javascript
53+
const { symbol, nameToUint64 } = require('eosjs-account-name');
3254

33-
Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/manh-vv/eosjs-name/settings). The name of this theme is saved in the Jekyll `_config.yml` configuration file.
55+
/**
56+
* cleos -u https://eos.greymass.com get scope eosio.token -t stat
57+
*/
58+
const name = '........ehbo5';
59+
const uint64 = nameToUint64(name);
60+
const symbolName = symbol.toName(uint64);
61+
62+
// expect(symbolName).toEqual('EOS');
63+
```
3464

35-
### Support or Contact
65+
## Note on random eosio name
66+
67+
In case you want to generate a random name, I suggest you use [`nanoid`](https://zelark.github.io/nano-id-cc/).
68+
69+
```javascript
70+
const generate = require('nanoid/generate');
71+
const alphabet = '.12345abcdefghijklmnopqrstuvwxyz';
72+
generate(alphabet, 12); //=> "nc4zs1yyg.jx"
73+
```
3674

37-
Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://github.com/contact) and we’ll help you sort it out.

0 commit comments

Comments
 (0)