|
1 |
| -## Welcome to GitHub Pages |
| 1 | +# Eosio name to uint64 |
2 | 2 |
|
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 | +[](https://www.npmjs.org/package/eosjs-account-name) |
| 4 | +[](https://travis-ci.org/manh-vv/eosjs-name) |
| 5 | +[](https://codecov.io/gh/manh-vv/eosjs-name) |
4 | 6 |
|
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 | +[](https://gitpod.io/#https://github.com/manh-vv/eosjs-name) |
6 | 8 |
|
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 | +``` |
8 | 30 |
|
9 |
| -Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for |
| 31 | +## From uint64 to name |
10 | 32 |
|
11 |
| -```markdown |
12 |
| -Syntax highlighted code block |
| 33 | +Source https://github.com/EOSIO/eos/blob/master/libraries/chain/name.cpp#L19 |
13 | 34 |
|
14 |
| -# Header 1 |
15 |
| -## Header 2 |
16 |
| -### Header 3 |
| 35 | +## Example |
17 | 36 |
|
18 |
| -- Bulleted |
19 |
| -- List |
| 37 | +Try on run-kit https://npm.runkit.com/eosjs-account-name |
20 | 38 |
|
21 |
| -1. Numbered |
22 |
| -2. List |
| 39 | +```javascript |
| 40 | +const eosjsAccountName = require('eosjs-account-name'); |
| 41 | +const n = eosjsAccountName.nameToUint64('eosio'); |
23 | 42 |
|
24 |
| -**Bold** and _Italic_ and `Code` text |
| 43 | +console.log('eosio to uint64: ' + n); |
25 | 44 |
|
26 |
| -[Link](url) and  |
| 45 | +console.log('uint64 to name: ' + eosjsAccountName.uint64ToName(n)); |
27 | 46 | ```
|
28 | 47 |
|
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) |
30 | 51 |
|
31 |
| -### Jekyll Themes |
| 52 | +```javascript |
| 53 | +const { symbol, nameToUint64 } = require('eosjs-account-name'); |
32 | 54 |
|
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 | +``` |
34 | 64 |
|
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 | +``` |
36 | 74 |
|
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