{"id":28862427,"url":"https://github.com/ecency/esteem-lib","last_synced_at":"2025-08-11T14:44:05.299Z","repository":{"id":57230611,"uuid":"83298000","full_name":"ecency/esteem-lib","owner":"ecency","description":"Multi-chain js library for eSteem, API for Steem/Golos","archived":false,"fork":false,"pushed_at":"2017-04-15T09:18:29.000Z","size":1528,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T05:49:11.776Z","etag":null,"topics":["app","blockchain","desktop","esteem","golos","mobile","steem"],"latest_commit_sha":null,"homepage":"http://www.esteem.ws","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ecency.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-27T10:29:48.000Z","updated_at":"2018-01-01T22:04:10.000Z","dependencies_parsed_at":"2022-09-08T20:41:29.481Z","dependency_job_id":null,"html_url":"https://github.com/ecency/esteem-lib","commit_stats":null,"previous_names":["esteemapp/esteem-lib"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ecency/esteem-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecency%2Festeem-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecency%2Festeem-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecency%2Festeem-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecency%2Festeem-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecency","download_url":"https://codeload.github.com/ecency/esteem-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecency%2Festeem-lib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269700862,"owners_count":24461468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["app","blockchain","desktop","esteem","golos","mobile","steem"],"created_at":"2025-06-20T06:10:52.842Z","updated_at":"2025-08-11T14:44:05.268Z","avatar_url":"https://github.com/ecency.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esteem-lib\n\nLibrary used by eSteem to construct, sign and broadcast transactions in Javascript to Steem and Golos chains. Can be used by browser Javascript and Node.js server side.\n\n[![npm version](https://img.shields.io/npm/v/esteem-lib.svg?style=flat-square)](https://www.npmjs.com/package/esteem-lib)\n[![npm downloads](https://img.shields.io/npm/dm/esteem-lib.svg?style=flat-square)](https://www.npmjs.com/package/esteem-lib)\n\n## Setup\n\nThis library can be obtained through npm:\n```\nnpm install esteem-lib\n```\n\n## Usage\n\nThree sub-libraries are included: `ECC`, `Chain` and `Serializer`. Generally only the `ECC` and `Chain` libraries need to be used directly.\n\n# Multi-chain\n\nIn order to change chain from Steem\u003c-\u003eGolos, you should first close open socket and change socket on RPC.\n\n\n```\nwindow.Api.close();\nwindow.Api = window.steemRPC.Client.get({url:\"wss://example.com\"}, true); //RPC\n\nwindow.esteem.ChainConfig.setChainId(\"0000000000000000000000000000000000000000000000000000000000000000\"); //steem\nwindow.esteem.ChainConfig.setChainId(\"782a3039b478c839e4cb0c941ff4eaeb7df40bdd68bd441afd444b9da763de12\"); //golos\n\n```\n\n### API setup\n\nWhen constructing a transaction and also when verifying the password/private key of an account, some data from the blockchain is required. Because of this, `esteem-lib` includes a dependency on [steem-rpc](https://github.com/svk31/steem-rpc), which is a websocket API library for connecting to Steem/Golos API servers. Before attempting to broadcast a transaction you will need to initialise this library. By default it will connect to a Steem public API server provided by [xeroc and jesta](https://steemit.com/steemws/@jesta/steem-ws-the-public-steem-api-cluster), but you can change this in the options if you prefer to use your own server.\n\nTo initialise the API library, use the following code:\n\n```\nvar options = {};\nvar {Client} = require('steem-rpc');\nvar Api = Client.get(options, true);\nApi.initPromise.then(response =\u003e {\n    console.log(\"Api ready:\", response);\n})\n```\n\nIn a browser the syntax is slightly different:\n\n```\nvar options = {};\nvar Client = window.esteem.steemRPC.Client;\nvar Api = Client.get(options, true);\nApi.initPromise.then(response =\u003e {\n    console.log(\"Api ready:\", response);\n})\n```\n\n\nMore details on the possible options can be found in the README of `steem-rpc`.\n\nOnce the init promise has been resolved, the API connection is ready and you can start using the transaction builder.\n\n\nDISCLAIMER: This is a work in progress and most likely there will be bugs. Please file issues if you encounter any problems.\n\nThe source code uses ES6 syntax but the npm library is transpiled to regular ES5 and can be used without Babel.\n\n## Tests\nThere's a quite extensive suite of tests that can be run using `npm run test`. These tests cover many different use cases and can be used as a reference point.\n\n\n### Chain\n\nThe Chain library contains utility functions related to the chain state, as well as a transaction builder and a login class.\n\n\n#### Transaction builder\nThe transaction builder can be used to construct any transaction, sign it, and broadcast it. To broadcast a transaction you need to be connected to a `steemd` node with the `network_broadcast_api` enabled.\n\nFor an example of how to create transaction, see below:\n\n```\n// First generate the private key using the Login class\nvar { TransactionBuilder, Login } = require(\"esteem-lib\");\nvar login = new Login();\nlogin.setRoles([\"posting\"]);\nvar loginSuccess = login.checkKeys({\n    accountName: \"myacccount\",\n    password: \"mypassword\",\n    auths: {\n        posting: [[\"STMpostingAuthKey\", 1]]\n    }}\n);\n\nif (!loginSuccess) {\n    throw new Error(\"The password or account name was incorrect\");\n}    \n// Then create the transaction and sign it without broadcasting\nvar tr = new TransactionBuilder();\ntr.add_type_operation(\"vote\", {\n    voter: \"myaccount,\n    author: \"seshadga\",\n    permlink: \"bitcoin-price-sustainability-looks-on-track\",\n    weight: 100\n});\n\ntr.process_transaction(login, null, false);\n```\n\nThe third argument of `process_transaction` is `broadcast`. Setting it to false will simply construct the transaction and serialize it, without broadcasting it. If you want it to broadcast immediately, set it to `true`.\n\n#### Operation types\nFor a list of possible operation types with their required and optional inputs, see this file: [operations.js](https://github.com/svk31/esteem-lib/blob/master/lib/serializer/src/operations.js).\n\n#### Login\nThe Chain library includes the Login class that can be used to \"log in\" using an account name and a corresponding password or private key. Logging in here simply means verifying that the private key or password provided can be used to generate the private key for that account. The verification checks the public keys of the given account.\n\nThe password used on [https://steemit.com](https://steemit.com) is compatible with this library. To run the Login tests, copy config.example.js and create a config.js. In this file you must provide two accounts, one with a password and one with a private key. The corresponding public keys can be found on [https://steemd.com](https://steemd.com).\n\nThe Login class uses the following format to generate private keys from account names and passwords:\n\n```\nkeySeed = accountName + role + password\n```\nWhere `role` can be one of `active, owner, posting, memo`.\n\nUsing this seed, private keys are generated for either the default roles `active, owner, posting, memo`, or as specified. A minimum password length of 12 characters is enforced, but an even longer password is recommended. Three methods are provided:\n\n```\ngenerateKeys(account, password, [roles])\nfromPrivKey(accountName, privateKey, [roles])\ncheckKeys({accountName, password, privateKey, auths})\nsignTransaction(tr)\ngetRoles()\nsetRoles([roles])\n```\n\nThe auths object should contain the auth arrays from the account object. An example is this:\n\n```\n{\n    active: [\n        [\"GPH5Abm5dCdy3hJ1C5ckXkqUH2Me7dXqi9Y7yjn9ACaiSJ9h8r8mL\", 1]\n    ]\n}\n```\n\nIf checkKeys is successful, you can use signTransaction to sign a TransactionBuilder transaction using the private keys for that account.\n\n### ECC\nThe ECC library contains all the crypto functions for private and public keys as well as transaction creation/signing.\n\n#### Private keys\nAs a quick example, here's how to generate a new private key from a seed (a brainkey for example):\n\n```\nvar {PrivateKey, key} = require(\"esteem-lib\");\n\nlet seed = \"THIS IS A TERRIBLE BRAINKEY SEED WORD SEQUENCE\";\nlet pkey = PrivateKey.fromSeed( key.normalize_brainKey(seed) );\n\nconsole.log(\"\\nPrivate key:\", pkey.toWif());\nconsole.log(\"Public key :\", pkey.toPublicKey().toString(), \"\\n\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecency%2Festeem-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecency%2Festeem-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecency%2Festeem-lib/lists"}