{"id":13454306,"url":"https://github.com/harpagon210/sscjs","last_synced_at":"2025-04-24T14:32:23.377Z","repository":{"id":41300839,"uuid":"148083865","full_name":"harpagon210/sscjs","owner":"harpagon210","description":"a light javascript library to interact with the Steem Smart Contracts Sidechain","archived":false,"fork":false,"pushed_at":"2023-03-02T07:38:59.000Z","size":1077,"stargazers_count":20,"open_issues_count":8,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T06:41:45.371Z","etag":null,"topics":["javascript","smart-contracts","steem","steemsmartcontracts"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harpagon210.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-09-10T01:45:13.000Z","updated_at":"2021-11-28T16:11:58.000Z","dependencies_parsed_at":"2024-01-16T04:30:56.284Z","dependency_job_id":"2ebda73a-8d53-4c68-aa26-de558df87f73","html_url":"https://github.com/harpagon210/sscjs","commit_stats":{"total_commits":30,"total_committers":2,"mean_commits":15.0,"dds":0.4666666666666667,"last_synced_commit":"829725c0e399eb5bcd998cf1b82ebd148a343d99"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harpagon210%2Fsscjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harpagon210%2Fsscjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harpagon210%2Fsscjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harpagon210%2Fsscjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harpagon210","download_url":"https://codeload.github.com/harpagon210/sscjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250643536,"owners_count":21464197,"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","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":["javascript","smart-contracts","steem","steemsmartcontracts"],"created_at":"2024-07-31T08:00:52.894Z","updated_at":"2025-04-24T14:32:23.060Z","avatar_url":"https://github.com/harpagon210.png","language":"JavaScript","funding_links":[],"categories":["Steem Engine"],"sub_categories":[],"readme":"\n\n  \n# [sscjs](https://github.com/harpagon210/sscjs) [![Build Status](https://travis-ci.org/harpagon210/sscjs.svg?branch=master)](https://travis-ci.org/harpagon210/sscjs)\n\nLight javascript library to interact with the JSON RPC server of [a Steem Smart Contracts node](https://github.com/harpagon210/steemsmartcontracts)\n\nInstallation\n------------\n\n### Via npm\n\nFor node.js or the browser with [browserify](https://github.com/substack/node-browserify) or [webpack](https://github.com/webpack/webpack).\n\n```\nnpm install sscjs\n```\n\n### From a cdn or self-hosted script\n\nGrab `dist/ssc.min.js` from a [release](https://github.com/harpagon210/sscjs/releases) and include in your html:\n\n```html\n\u003cscript src=\"ssc.min.js\"\u003e\u003c/script\u003e\n```\n\nor from the [jsdelivr](https://cdn.jsdelivr.net) cdn:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/sscjs@latest/dist/ssc.min.js\"\u003e\u003c/script\u003e\n```\n\n\nUsage\n-----\n\n### In the browser\nThis library requires the [axios library](https://github.com/axios/axios)\n\n```html\n\u003cscript src=\"https://unpkg.com/axios/dist/axios.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/sscjs@latest/dist/ssc.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    const ssc = new SSC('https://testapi.steem-engine.com');\n    ssc.getLatestBlockInfo((err, result) =\u003e {\n\t\tconsole.log(err, result);\n\t});\n\u003c/script\u003e\n```\n\n### In node.js\n\n```javascript\nconst SSC = require('sscjs');\n\nconst ssc = new SSC('https://testapi.steem-engine.com');\nssc.stream((err, res) =\u003e {\n\tconsole.log(err, res);\n});\n```\n\nAvailable methods\n-----\n\n```javascript\n/**\n\n* Get the information of a contract (owner, source code, etc...)\n\n* @param  {String}  name contract name\n\n* @param  {Function}  callback callback called if passed\n\n* @returns  {Promise\u003cJSON\u003e} returns a promise if no callback passed\n\n*/\n\ngetContractInfo(contract, callback  =  null)\n\n// example\nssc.getContractInfo('tokens', (err, result) =\u003e {\n\tconsole.log(err, result);\n\t/*\n\t{\n\t    \"name\": \"tokens\",\n\t    \"owner\": \"steemsc\",\n\t    \"code\": \"...source code of the contract...\",\n\t    \"tables\": [\n\t        \"tokens_tokens\",\n\t\t...\n\t    ],\n\t    \"$loki\": 1\n\t}\n\t*/\n})\n```\n\n```javascript\n/**\n\n* retrieve a record from the table of a contract\n\n* @param  {String}  contract contract name\n\n* @param  {String}  table table name\n\n* @param  {JSON}  query query to perform on the table\n\n* @param  {Function}  callback callback called if passed\n\n* @returns  {Promise\u003cJSON\u003e} returns a promise if no callback passed\n\n*/\n\nfindOne(contract, table, query, callback  =  null)\n\n// example\n// See https://github.com/techfort/LokiJS/wiki/Query-Examples for the available params\nssc.findOne(\n\t'tokens', \n\t'balances', \n\t{ \n\t\taccount:  'harpagon' \n\t}, (err, result) =\u003e {\n\n\tconsole.log(err, result);\n\t/*\n\t{\n            \"account\": \"harpagon\",\n            \"symbol\": \"SSC\",\n            \"balance\": 3.0005,\n            \"$loki\": 6\n        }\n\t*/\n})\n```\n\n```javascript\n/**\n   * retrieve records from the table of a contract\n   * @param {String} contract contract name\n   * @param {String} table table name\n   * @param {JSON} query query to perform on the table\n   * @param {Integer} limit limit the number of records to retrieve\n   * @param {Integer} offset offset applied to the records set\n   * @param {Array\u003cObject\u003e} indexes array of index definitions { index: string, descending: boolean }\n   * @param {Function} callback callback called if passed\n   * @returns {Promise\u003cJSON\u003e} returns a promise if no callback passed\n*/\n\nfind(contract, table, query, limit = 1000, offset = 0, indexes = [], callback = null) \n\n// example\n// See https://github.com/techfort/LokiJS/wiki/Query-Examples for the available params\n\nssc.find('tokens', 'tokens', { }, 1000, 0, [], (err, result) =\u003e {\n\tconsole.log(err, result);\n\t/*\n\t[\n\t    \t{\n\t\t    \"issuer\": \"steemsc\",\n\t\t    \"symbol\": \"STEEMP\",\n\t\t    \"name\": \"STEEM Pegged\",\n\t\t    \"precision\": 3,\n\t\t    \"maxSupply\": 1000000000000,\n\t\t    \"supply\": 1000000000000,\n\t\t    \"$loki\": 1\n\t\t},\n\t\t{\n\t\t    \"issuer\": \"null\",\n\t\t    \"symbol\": \"SSC\",\n\t\t    \"name\": \"Steem Smart Contracts Token\",\n\t\t    \"url\": \"https://steemsmartcontracts.com\",\n\t\t    \"precision\": 8,\n\t\t    \"maxSupply\": 1000000000000,\n\t\t    \"supply\": 250000000,\n\t\t    \"$loki\": 2\n\t\t},\n\t]\n\t*/\n})\n```\n\n```javascript\n/**\n\n* retrieve the latest block info of the sidechain\n\n* @param  {Function}  callback callback called if passed\n\n* @returns  {Promise\u003cJSON\u003e} returns a promise if no callback passed\n\n*/\n\ngetLatestBlockInfo(callback  =  null)\n\n// example\nssc.getLatestBlockInfo((err, result) =\u003e {\n\tconsole.log(err, result);\n\t/*\n\t{\n\t    \"blockNumber\": 12,\n\t    \"refSteemBlockNumber\": 25797141,\n\t    \"previousHash\": \"9389c132270c7335b806a43bd063110fe3868015f96db80470bef2f48f1c2fcb\",\n\t    \"timestamp\": \"2018-09-09T02: 48: 48\",\n\t    \"transactions\": [\n\t        {\n\t            \"refSteemBlockNumber\": 25797141,\n\t            \"transactionId\": \"b299d24be543cd50369dbc83cf6ce10e2e8abc9b\",\n\t            \"sender\": \"smmarkettoken\",\n\t            \"contract\": \"smmkt\",\n\t            \"action\": \"updateBeneficiaries\",\n\t            \"payload\": {\n\t                \"beneficiaries\": [\n\t                    \"harpagon\"\n\t                ],\n\t                \"isSignedWithActiveKey\": true\n\t            },\n\t            \"hash\": \"ac33d2fcaf2d72477483ab1f2ed4bf3bb077cdb55d5371aa896e8f3fd034e6fd\",\n\t            \"logs\": \"{}\"\n\t        }\n\t    ],\n\t    \"hash\": \"e97e4b9a88b4ac5b8ed5f7806738052d565662eec962a0c0bbd171672a4a54d4\",\n\t    \"merkleRoot\": \"2f1221ae1938bc24f3ed593e8c57ea41882fedc5d31de21da9c9bd613360f3a6\"\n\t}\n\t*/\n})\n```\n\n\n```javascript\n/**\n\n* retrieve the specified block info of the sidechain\n\n* @param  {Number}  blockNumber block number\n\n* @param  {Function}  callback callback called if passed\n\n* @returns  {Promise\u003cJSON\u003e} returns a promise if no callback passed\n\n*/\n\ngetBlockInfo(blockNumber, callback  =  null)\n\n// example\nssc.getBlockInfo(12, (err, result) =\u003e {\n\tconsole.log(err, result);\n\t/*\n\t{\n\t    \"blockNumber\": 12,\n\t    \"refSteemBlockNumber\": 25797141,\n\t    \"previousHash\": \"9389c132270c7335b806a43bd063110fe3868015f96db80470bef2f48f1c2fcb\",\n\t    \"timestamp\": \"2018-09-09T02: 48: 48\",\n\t    \"transactions\": [\n\t        {\n\t            \"refSteemBlockNumber\": 25797141,\n\t            \"transactionId\": \"b299d24be543cd50369dbc83cf6ce10e2e8abc9b\",\n\t            \"sender\": \"smmarkettoken\",\n\t            \"contract\": \"smmkt\",\n\t            \"action\": \"updateBeneficiaries\",\n\t            \"payload\": {\n\t                \"beneficiaries\": [\n\t                    \"harpagon\"\n\t                ],\n\t                \"isSignedWithActiveKey\": true\n\t            },\n\t            \"hash\": \"ac33d2fcaf2d72477483ab1f2ed4bf3bb077cdb55d5371aa896e8f3fd034e6fd\",\n\t            \"logs\": \"{}\"\n\t        }\n\t    ],\n\t    \"hash\": \"e97e4b9a88b4ac5b8ed5f7806738052d565662eec962a0c0bbd171672a4a54d4\",\n\t    \"merkleRoot\": \"2f1221ae1938bc24f3ed593e8c57ea41882fedc5d31de21da9c9bd613360f3a6\"\n\t}\n\t*/\n})\n```\n\n```javascript\n/**\n\n* retrieve the specified transaction info of the sidechain\n\n* @param  {String}  txid transaction id\n\n* @param  {Function}  callback callback called if passed\n\n* @returns  {Promise\u003cJSON\u003e} returns a promise if no callback passed\n\n*/\n\ngetTransactionInfo(txid, callback  =  null)\n\n// example\nssc.getTransactionInfo('b299d24be543cd50369dbc83cf6ce10e2e8abc9b', (err, result) =\u003e {\n\tconsole.log(err, result);\n\t/*\n\t{\n\t    \"blockNumber\": 12,\n\t    \"refSteemBlockNumber\": 25797141,\n\t    \"transactionId\": \"b299d24be543cd50369dbc83cf6ce10e2e8abc9b\",\n\t    \"sender\": \"smmarkettoken\",\n\t    \"contract\": \"smmkt\",\n\t    \"action\": \"updateBeneficiaries\",\n\t    \"payload\": {\n\t\t\"beneficiaries\": [\n\t\t    \"harpagon\"\n\t\t],\n\t\t\"isSignedWithActiveKey\": true\n\t    },\n\t    \"hash\": \"ac33d2fcaf2d72477483ab1f2ed4bf3bb077cdb55d5371aa896e8f3fd034e6fd\",\n\t    \"logs\": \"{}\"\n\t}\n\t*/\n})\n```\n\n```javascript\n/**\n\n* stream part of the sidechain\n\n* @param  {Number}  startBlock the first block to retrieve\n\n* @param  {Number}  endBlock if passed the stream will stop after the block is retrieved\n\n* @param  {Function}  callback callback called everytime a block is retrieved\n\n* @param  {Number}  pollingTime polling time, default 1 sec\n\n*/\n\nstreamFromTo(startBlock, endBlock  =  null, callback, pollingTime  =  1000)\n\n// example\nssc.streamFromTo(0, 12, (err, result) =\u003e {\n\tconsole.log(err, result);\n\t/*\n\t{\n\t    \"blockNumber\": 12,\n\t    \"refSteemBlockNumber\": 25797141,\n\t    \"previousHash\": \"9389c132270c7335b806a43bd063110fe3868015f96db80470bef2f48f1c2fcb\",\n\t    \"timestamp\": \"2018-09-09T02: 48: 48\",\n\t    \"transactions\": [\n\t        {\n\t            \"refSteemBlockNumber\": 25797141,\n\t            \"transactionId\": \"b299d24be543cd50369dbc83cf6ce10e2e8abc9b\",\n\t            \"sender\": \"smmarkettoken\",\n\t            \"contract\": \"smmkt\",\n\t            \"action\": \"updateBeneficiaries\",\n\t            \"payload\": {\n\t                \"beneficiaries\": [\n\t                    \"harpagon\"\n\t                ],\n\t                \"isSignedWithActiveKey\": true\n\t            },\n\t            \"hash\": \"ac33d2fcaf2d72477483ab1f2ed4bf3bb077cdb55d5371aa896e8f3fd034e6fd\",\n\t            \"logs\": \"{}\"\n\t        }\n\t    ],\n\t    \"hash\": \"e97e4b9a88b4ac5b8ed5f7806738052d565662eec962a0c0bbd171672a4a54d4\",\n\t    \"merkleRoot\": \"2f1221ae1938bc24f3ed593e8c57ea41882fedc5d31de21da9c9bd613360f3a6\"\n\t}\n\t*/\n})\n```\n\n```javascript\n/**\n\n* stream the sidechain (starting from the latest block produced)\n\n* @param  {Function}  callback callback called everytime a block is retrieved\n\n* @param  {Number}  pollingTime polling time, default 1 sec\n\n*/\n\nstream(callback, pollingTime  =  1000)\n\n// example\nssc.stream((err, result) =\u003e {\n\tconsole.log(err, result);\n\t/*\n\t{\n\t    \"blockNumber\": 12,\n\t    \"refSteemBlockNumber\": 25797141,\n\t    \"previousHash\": \"9389c132270c7335b806a43bd063110fe3868015f96db80470bef2f48f1c2fcb\",\n\t    \"timestamp\": \"2018-09-09T02: 48: 48\",\n\t    \"transactions\": [\n\t        {\n\t            \"refSteemBlockNumber\": 25797141,\n\t            \"transactionId\": \"b299d24be543cd50369dbc83cf6ce10e2e8abc9b\",\n\t            \"sender\": \"smmarkettoken\",\n\t            \"contract\": \"smmkt\",\n\t            \"action\": \"updateBeneficiaries\",\n\t            \"payload\": {\n\t                \"beneficiaries\": [\n\t                    \"harpagon\"\n\t                ],\n\t                \"isSignedWithActiveKey\": true\n\t            },\n\t            \"hash\": \"ac33d2fcaf2d72477483ab1f2ed4bf3bb077cdb55d5371aa896e8f3fd034e6fd\",\n\t            \"logs\": \"{}\"\n\t        }\n\t    ],\n\t    \"hash\": \"e97e4b9a88b4ac5b8ed5f7806738052d565662eec962a0c0bbd171672a4a54d4\",\n\t    \"merkleRoot\": \"2f1221ae1938bc24f3ed593e8c57ea41882fedc5d31de21da9c9bd613360f3a6\"\n\t}\n\t*/\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharpagon210%2Fsscjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharpagon210%2Fsscjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharpagon210%2Fsscjs/lists"}