{"id":21528513,"url":"https://github.com/fibercrypto/libjs-skycoin","last_synced_at":"2026-05-05T04:03:01.177Z","repository":{"id":44103674,"uuid":"130534085","full_name":"fibercrypto/libjs-skycoin","owner":"fibercrypto","description":"Javascript (web \u0026 node) client library for the Skycoin API","archived":false,"fork":false,"pushed_at":"2022-12-31T02:06:37.000Z","size":5224,"stargazers_count":0,"open_issues_count":25,"forks_count":2,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-01-24T06:11:18.050Z","etag":null,"topics":["client-lib","client-lib-js","client-library","javascript","javascript-library","js","js-library","js-libs","nodejs","nodejs-library","nodejs-module","nodejs-modules","openapi","rest-api","restapi","skycoin","swagger","swig"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/fibercrypto.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":"2018-04-22T04:06:45.000Z","updated_at":"2019-11-03T00:56:39.000Z","dependencies_parsed_at":"2023-01-31T17:31:44.364Z","dependency_job_id":null,"html_url":"https://github.com/fibercrypto/libjs-skycoin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibercrypto%2Flibjs-skycoin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibercrypto%2Flibjs-skycoin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibercrypto%2Flibjs-skycoin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibercrypto%2Flibjs-skycoin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibercrypto","download_url":"https://codeload.github.com/fibercrypto/libjs-skycoin/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244092027,"owners_count":20396724,"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":["client-lib","client-lib-js","client-library","javascript","javascript-library","js","js-library","js-libs","nodejs","nodejs-library","nodejs-module","nodejs-modules","openapi","rest-api","restapi","skycoin","swagger","swig"],"created_at":"2024-11-24T01:53:31.444Z","updated_at":"2026-05-05T04:02:56.141Z","avatar_url":"https://github.com/fibercrypto.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LibSkycoin for Javascript\n\n[![Build Status](https://travis-ci.org/simelo/libjs-skycoin.svg?branch=develop)](https://travis-ci.org/simelo/libjs-skycoin)\n\nJavascript client library for Skycoin API. This library is a Javascript assembly generated with SWIG to access Skycoin API from Javascript.\n\n## Table of Contents\n\n\u003c!-- MarkdownTOC levels=\"1,2,3,4,5\" autolink=\"true\" bracket=\"round\" --\u003e\n\n- [LibJS-skycoin wrappers for the Skycoin cipher](#libjs-skycoin-wrappers-for-the-skycoin-cipher)\n  - [Installation](#installation)\n  - [Using the API](#usage)\n    - [Naming](#naming)\n    - [Parameters](#parameters)\n      - [Handles](#handles)\n      - [Byte Slices](#byte-slices)\n      - [Structures](#structures)\n      - [Fixed Sized Arrays](#fixed-sized-arrays)\n      - [Other Slices](#other-slices)\n    - [Memory Managemanet](#memory-management)\n- [Make rules](#make-rules)\n- [Development setup](#development-setup)\n- [LibJS Skycoin wrappers for the Skycoin client API](#libjs-skycoin-wrappers-for-the-skycoin-client-api)\n  - [Clients](#clients)\n  - [LibSky-Axios Client](#libsky-axios-client)\n  - [LibSky-Node Client](#libsky-node-client)\n  \u003c!-- /MarkdownTOC --\u003e\n\n## LibJS Skycoin wrappers for the Skycoin cipher\n\n**LibJS Skycoin** is an assembly that provides wrappers to the Skycoin core cipher API's, implemented in `golang`, hence linking directly to the original node code. No transpilation involved.\n\n### Installation\n\nBefore installing, make sure you understand the choices available to [install a NPM package](https://docs.npmjs.com/about-npm) . For instance, in case of [installing NPM client tools](https://docs.npmjs.com/getting-started/) the process would look like this, using [`npm install` command](https://docs.npmjs.com/packages-and-modules/).\n\n```sh\n\nnpm install libskycoin\n```\n\n### Install from sources\n\nDownload the repository from http://github.com/simelo/libjs-skycoin.git.\nExecute (`make build`) to install the library.\n\n### Usage\n\n#### Naming\n\nThe exported function in Libskycoin JS have the following naming format: `SKY_package_func_name` where package is replace by the package where the original Skycoin function is and func_name is the name of the function. For example, `LoadConfig` function from `cli` package is called in .Net `SKY_cli_LoadConfig`\n\n#### Parameters\n\nAll skycoin exported functions return an error object as the last of the return parameters. In .NET error is return as an `uint` and it is the first return parameter. The rest of the parameters are returned in the same order.\n\nReceivers in Skycoin are the first of the input parameters. Simple types, like integer, float, string will be used as the corresponding types in JS, except what act as pointers.\n\n##### Handles\n\nSome of Skycoin types are too complex to be exported to a scripting language. So, handles are used instead. Therefore all functions taking a complex type will receive a handle instead of the original Skycoin type. For example, having these functions exported from Skycoin:\n\n```go\n  func LoadConfig() (Config, error)\n  func (c Config) FullWalletPath() string\n```\n\nConfig is a struct type that is treated as a handle in Libskycoin JS . The usage in .Net will be:\n\n```js\n      var skycoin = require('./lib/skycoin/build/Release/skycoin');\n      var configHandle = skycoin.new_Config_HandlePtr();\n      var err = skycoin.SKY_cli_LoadConfig(configHandle);\n      if(err == skycoin.SKY_OK) {\n        // SkY_OK means no error\n        var fullWalletPath = new _GoString()_;\n        err = skycoin.SKY_cli_FullWalletPath(configHandle,fullWallerPath);\n        //Close the handle after using the it\n        //so the garbage collector can delete the object associated with  it.\n        skycoin.SKY_handle_close( configHandle );\n      } else {\n        // #Error\n      }\n    }\n  }\n}\n```\n\n##### Byte slices\n\nParameters of type byte[] will treated as string . Example, this function in Skycoin:\n\n```go\nfunc (s ScryptChacha20poly1305) Encrypt(data, password []byte) ([]byte, error)\n```\n\n... should be invoked like this:\n\n```js\nvar encrypt_settings = new skycoin.encrypt__ScryptChacha20poly1305();\nvar data = new skycoin.GoSlice(); //It will be passed as a parameter of type []byte\nvar pwd = new skycoin.GoSlice(); //As []byte too\nvar dataStr = new skycoin._GoString();\nvar pwdStr = new skycoin._GoString();\nvar encrypted = new skycoin.GoSlice();\n\ndataStr.setString(\"Data to encrypt\" );\ndata.convertString(dataStr);\npwdStr.SetString(\"password\");\npwd.convertString(pwdStr);\n\nvar err = skycoin.SKY_encrypt_ScryptChacha20poly1305_Encrypt(encrypt_settings, data, pwd,encrypted);\nif(err == skycoin.SKY_OK){\n  encrypted.getString().p); //Encrypted is GoSlice\n}\n```\n\n##### Structures\n\nStructures that are not exported as handles are treated like JS classes. In the previous example type ScryptChacha20poly1305 is created in JS like:\n\n```js\nvar encrypt_settings = new skycoin.encrypt__ScryptChacha20poly1305()\n```\n\nAnd passed as first parameter in call to `SKY_encrypt_ScryptChacha20poly1305_Encrypt`.\n\n##### Fixed Sized Arrays\n\nParameters of fixed size array are wrapped in structures when called from JS.\n\nGiven these types in Skycoin and this exported function:\n\n```go\n  type PubKey [33]byte\n  type SecKey [32]byte\n\n  func GenerateDeterministicKeyPair(seed []byte) (PubKey, SecKey)\n```\n\nThis is a way to use them to write assertions in JS:\n\n```js\n//Generates random seed\nvar data = new skycoin.GoSlice();\nvar err = skycoin.SKY_cipher_RandByte(32,data);\n\n\nvar pubkey = new skycoin.cipher_PubKey();\nvar seckey = new skycoin.cipher_SecKey();\n\nerr = skycoin.SKY_cipher_GenerateDeterministicKeyPair(data, pubkey,seckey);\n```\n\nIn the example above `pubkey` and `seckey` are objects of an structure type containing a field named `data` holding the corresponding instance of `PubKey` and `SecKey`. Something like:\n\n```cpp\n  cipher_PubKey struct{\n    data [33]byte;\n  } cipher_PubKey;\n\n  cipher_SecKey struct{\n    data [32]byte;\n  } ;\n```\n\n##### Other Slices\n\nOther slices of base type different from `byte` are indeed wrapped inside classes. Let's see how to call the following function:\n\n```go\nfunc GenerateDeterministicKeyPairs(seed []byte, n int) []SecKey\n```\n\nIn Javascript this how it should be used to generate a deterministic sequence of pairs of public / private keys given a random seed:\n\n```js\n//Generates random seed\nvar seed = new skycoin.GoSlice();\nvar err = skycoin.SKY_cipher_RandByte(32,seed);\nvar seckeys = new skycoin.cipher__SecKeys();\n\nerr = skycoin.SKY_cipher_GenerateDeterministicKeyPairs(seed, 2,seckeys);\n\nfor(int i=0;i\u003cseckeys.count,i++){\n  var pubkey = new skycoin.cipher_PubKey();\n  var seckey = new skycoin.cipher_SecKey();\n  seckeys.getAt(seckey,i);\n\n  skycoin.SKY_cipher_PubKeyFromSecKey(seckey, pubkey);\n  err = skycoin.SKY_cipher_PubKey_Verify(pubkey);\n}\n```\n\n### Memory Management\n\nMemory management is transparent to the user. Any object allocated inside the library is left to be managed by the JS garbage collector.\n\n## Make Rules\n\nThe following `make` rules are available after `git checkout` of this repository. They all require [Skycoin](https://github.com/skycoin/libskycoin) to be checked out as a `git submodule` of libskycoin JS .\n\n```\n$ make help\n\ninstall                        Build all libraries and tester\ntest                           Test all clients\ntest-node-client               Test node client\ntest-axios-client              Test axios client\nbuild-axios-client             Build axios client\nbuild-node-client              Build node client\nbuild-node-tester              Build node client tester\nbuild-axios-tester             Build tester\nconfigure                      Configure build environment\nbuild-libc                     Build libskycoin C client library\nbuild-swig                     Generate Node C module from SWIG interfaces\nbuild-libsky-shared            Build shared library including SWIG wrappers\n```\n\n## Development setup\n\nIt is highly recommended for developers to setup their environment using\nthe available Docker images.\nRead the [LibJS Skycoin Docker docs](docker/images/dev-cli/README.md) for further\ndetails.\n\nThe project has two branches: `master` and `develop`.\n\n- `develop` is the default branch and will always have the latest code.\n  The submodule at `gopath/src/github.com/skycoin/libskycoin` has to be\n  in sync with `skycoin/libskycoin` `develop` branch.\n- `master` will always be equal to the current stable release on the website, and should correspond with the latest release tag.\n  The submodule at `gopath/src/github.com/skycoin/libskycoin` has to be\n  in sync with `skycoin/libskycoin` `master` branch.\n\nSeparate stable development branches will be created to work on releases for supporting the\nmost recent stable version of Skycoin. The name of these branches should be the Skycoin\nmajor and minor version numbers followed by `dev` suffix e.g. `0.25dev`.\nThese branches may be forked out of either `master` or `develop` branches, and\nthe submodule at `gopath/src/github.com/skycoin/libskycoin` has to be\nin sync with the corresponding tag of `skycoin/libskycoin` official repository.\n\nStable development branches are created most of the time for the following reasons:\n\n- A Skycoin release increasing [patch version number](https://semver.org/).\n- Enhanced support and bug fixes for a version of LibJS Skycoin compiled against an\n  stable version of Skycoin\n- Backporting useful features added in `develop`.\n\n### Running tests\n\n```sh\n$ make test\n```\n\n### Releases\n\n#### Update the version\n\n0. If the `master` branch has commits that are not in `develop` (e.g. due to a hotfix applied to `master`), merge `master` into `develop` (and fix any build or test failures)\n1. Switch to a new release branch named `release-X.Y.Z` for preparing the release.\n2. Ensure that the submodule at `gopath/src/github.com/skycoin/libskycoin` is in sync with respect to the corresponding tag in https://github.com/skycoin/libskycoin repository.\n4. Run `make build` to make sure that the code base is up to date\n5. Update `CHANGELOG.md`: move the \"unreleased\" changes to the version and add the date.\n6. Follow the steps in [pre-release testing](#pre-release-testing)\n7. Make a PR merging the release branch into `master`\n8. Review the PR and merge it\n9. Update files in https://github.com/skycoin/repo-info/tree/master/repos/skycoin/remote for `skycoin/skycoindev-js` Docker image, adding a new file for the new version and adjusting any configuration text that may have changed\n10. Tag the `master` branch with the version number. Version tags start with `v`, e.g. `v0.20.0`. Sign the tag. If you have your GPG key in github, creating a release on the Github website will automatically tag the release. It can be tagged from the command line with `git tag -as v0.20.0 $COMMIT_ID`, but Github will not recognize it as a \"release\".\n11. Release builds are created and uploaded by travis. To do it manually, checkout the master branch and follow the [create release builds instructions](#creating-release-builds).\n12. Checkout `develop` branch and bump package up to next [`dev` version number](https://docs.microsoft.com/en-us/nuget/create-packages/prerelease-packages).\n\n#### Pre-release testing\n\nPerform these actions before releasing:\n\n    make test\n\n#### Creating release builds\n\nRelease builds should be created from `master` branch . After [updating release version](#update-the-version) it is necessary to follow these steps\n\n##### Requirements\n\nHave installed the `node-gyp` for the creation of the package.\n\nhttps://www.npmjs.com/package/node-gyp\n\n##### Building\n\n    make build\n\nFinal results are placed in the lib/skycoin/build/Release/ folder.\n\n## LibJS Skycoin wrappers for the Skycoin client API\n\n**LibJS Skycoin** contains different clients libraries generated using [SWAGGER](https://swagger.io/) tools from the latest [OpenApi Specification](https://www.openapis.org/)  in the [GitHub Repository](https://github.com/simelo/libskycoin/tree/develop/lib/swagger) of **LibSkycoin**.\n\n### Clients\n\n| Name            | Swagger Generator |\n| :-------------: | :---------------: |\n| libsky-axios    |  typescript-axios |\n| libsky-node     |  typescript-node  |\n\n### LibSky-Axios Client\n\n**LibSky-Axios** is the client library generated using the typescript-axios Swagger generator.\n\n#### Installation\n\nBefore installing, make sure you understand the choices available to [install a NPM package](https://docs.npmjs.com/about-npm) . For instance, in case of [installing NPM client tools](https://docs.npmjs.com/getting-started/) the process would look like this, using [`npm install` command](https://docs.npmjs.com/packages-and-modules/).\n\n```sh\n\nnpm install libsky-axios\n```\n\n#### Install from sources\n\nDownload the repository from http://github.com/simelo/libjs-skycoin.git.\nExecute (`make build`) to build the library. Then\n\n```sh\nnpm install PATH_TO_REPOSITORY/lib/skyapi/axios\n```\n\n#### Usage\n\nOnce installed to your project you can use the library as in the example below.\n\n```js\n\"use strict\";\n\nlet libsky = require('libsky-axios'); // Import the library\n\nlet clientConfig = new libsky.Configuration(); // Create a basic client configuration object\n\nconst nodeUrl = 'https://node.skycoin.net'; // Url to a Skycoin Node\n\nlet client = new libsky.DefaultApi(clientConfig, nodeUrl); // Create a client object\n\nclient.version().then( // Get version data from nodeUrl\n    result =\u003e {\n      console.log(result.data);\n      // Print the Version Object in result.data\n    }\n);\n```\n\n### LibSky-Node Client\n\n**LibSky-Node** is the client library generated using the typescript-node Swagger generator.\n\n#### Installation\n\nBefore installing, make sure you understand the choices available to [install a NPM package](https://docs.npmjs.com/about-npm) . For instance, in case of [installing NPM client tools](https://docs.npmjs.com/getting-started/) the process would look like this, using [`npm install` command](https://docs.npmjs.com/packages-and-modules/).\n\n```sh\n\nnpm install libsky-node\n```\n\n#### Install from sources\n\nDownload the repository from http://github.com/simelo/libjs-skycoin.git.\nExecute (`make build`) to build the library. Then\n\n```sh\nnpm install PATH_TO_REPOSITORY/lib/skyapi/node\n```\n\n#### Usage\n\nOnce installed to your project you can use the library as in the example below.\n\n```js\n\"use strict\";\n\nlet libsky = require('libsky-node'); // Import the library\n\nconst nodeUrl = 'https://node.skycoin.net'; // Url to a Skycoin Node\n\nlet client = new libsky.DefaultApi(nodeUrl); // Create a client object\n\nclient.version().then( // Get version data from nodeUrl\n    result =\u003e {\n      console.log(result.data);\n      // Print the Version Object in result.data\n    }\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibercrypto%2Flibjs-skycoin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibercrypto%2Flibjs-skycoin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibercrypto%2Flibjs-skycoin/lists"}