{"id":25972826,"url":"https://github.com/jibrelnetwork/jibrel-contracts-jsapi","last_synced_at":"2025-03-05T01:17:33.835Z","repository":{"id":26013624,"uuid":"99794114","full_name":"jibrelnetwork/jibrel-contracts-jsapi","owner":"jibrelnetwork","description":"web3 wrapper for Jibrel smart contracts","archived":false,"fork":false,"pushed_at":"2022-12-10T01:51:01.000Z","size":2188,"stargazers_count":3,"open_issues_count":9,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-02T08:18:30.660Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jibrelnetwork.github.io/jibrel-contracts-jsapi/","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/jibrelnetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-09T10:05:22.000Z","updated_at":"2024-04-04T20:43:49.000Z","dependencies_parsed_at":"2023-01-14T09:30:55.150Z","dependency_job_id":null,"html_url":"https://github.com/jibrelnetwork/jibrel-contracts-jsapi","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjibrel-contracts-jsapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjibrel-contracts-jsapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjibrel-contracts-jsapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjibrel-contracts-jsapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jibrelnetwork","download_url":"https://codeload.github.com/jibrelnetwork/jibrel-contracts-jsapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241945530,"owners_count":20046870,"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":[],"created_at":"2025-03-05T01:17:33.230Z","updated_at":"2025-03-05T01:17:33.818Z","avatar_url":"https://github.com/jibrelnetwork.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jibrel-contracts-jsapi\n\nweb3 wrapper for jibrel-contracts\n\n[Exhaustive API description](https://jibrelnetwork.github.io/jibrel-contracts-jsapi/)\n\n  * [jibrel-contracts-jsapi](#jibrel-contracts-jsapi)\n    * [About](#about)\n    * [Get Started](#get-started)\n      * [Available npm scripts](#available-npm-scripts)\n    * [Public API definitions](#public-api-definitions)\n      * [ETH](#eth-api)\n      * [ERC20](#erc20-api)\n      * [ERC20Mintable](#erc20mintable-api)\n      * [ERC20Named](#erc20named-api)\n      * [Controller](#controller-api)\n      * [getAddressFromPrivateKey](#getaddressfromprivatekeyprivatekey)\n    * [Testing](#testing)\n      * [Steps to launch tests from jibrel-contracts](#steps-to-launch-tests-from-jibrel-contracts)\n\n## About\n\njibrel-contracts-jsapi is a set of stateless methods that make easier work with Ethereum blockchain, ERC20 Tokens and Jibrel Network contracts.\n\n## Get Started\n\n```\nnpm install @jibrelnetwork/contracts-jsapi\n```\n\n```javascript\nconst jibrelContractsJsapi = require('@jibrelnetwork/contracts-jsapi')\n```\n\n### Available npm scripts:\n\n  * `compile:standalone`: build:standalone \u0026 minify\n  * `compile`: lint \u0026 build\n  * `clean`: cleans `./lib` dir\n  * `build`: cleans \u0026 compiles library\n  * `build:standalone`: builds standalone webpack bundle to test library in browser without including it somewhere\n  * `lint`: check code-style errors\n  * `minify`: minifies webpack standalone bundle\n  * `test`: runs mocha tests\n  * `docs`: compile jsdocs\n  * `docs:open`: open docs index.html\n\n## Public API definitions\n\nSee [mocha tests](https://github.com/jibrelnetwork/jibrel-contracts-jsapi/tree/master/test) for examples of usage\n\n### `ETH` API\n\nweb3.eth functions wrapper\n\n#### eth.sendTransaction(props)\n\nSends transaction. Returns Promise that will be resolved with the hash of created transaction.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * privateKey: Private key (64 hex symbols, without '0x' prefix)\n  * to: Address of the transaction receiver\n  * value: Transaction value\n  * gasLimit: (optional) Gas limit for the transaction\n  * gasPrice: (optional) Gas price for the transaction\n  * nonce: (optional) Nonce for the transaction\n  * data: (optional) Transaction data\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getBalance(props)\n\nReturns Promise that will be resolved with balance of the provided address.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * address: Address to check balance\n  * defaultBlock: (optional) Redefines of web3.eth.defaultBlock\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getBlockNumber(props)\n\nReturns Promise that will be resolved with current block number.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getBlock(props)\n\nReturns Promise that will be resolved with block data.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * blockId: (optional) Block number or hash. Or the string \"earliest\"/\"latest\"/\"pending\"\n  * returnTransactionObjects: (optional) Return all transactions as objects if true\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getTransaction(props)\n\nReturns Promise that will be resolved with transaction data.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * transactionHash: Transaction hash\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getTransactionReceipt(props)\n\nReturns Promise that will be resolved with transaction receipt.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * transactionHash: Transaction hash\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getLogsFilter(props)\n\nReturns Promise that will be resolved with filter object, that can be used for getting of past logs or watching of new.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * options: (optional) Event options\n    * fromBlock: (optional) The number of the earliest block\n    * toBlock: (optional) The number of the latest block\n    * address: (optional) An address(es) to get logs from\n    * topics: (optional) Allows to manually set the topics for the event filter\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getPastLogs(props)\n\nReturns Promise that will be resolved with past logs.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * options: (optional) Event options\n    * fromBlock: (optional) The number of the earliest block\n    * toBlock: (optional) The number of the latest block\n    * address: (optional) An address(es) to get logs from\n    * topics: (optional) Allows to manually set the topics for the event filter\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.estimateGas(props)\n\nReturns Promise that will be resolved with estimate gas value.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * to: Address of the transaction receiver\n  * value: Transaction value\n  * data: (optional) Transaction data\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getGasPrice(props)\n\nReturns Promise that will be resolved with current gas price value.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### eth.getNonce(props)\n\nReturns Promise that will be resolved with current transaction count value for address specified\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * ssl: (optional) Defines using of ssl for connection or not\n  * address: Address to get transaction count\n  * defaultBlock: (optional) Redefines of web3.eth.defaultBlock\n\n\n### `ERC20` API\n\n#### contracts.erc20.totalSupply(props)\n\nReturns Promise that will be resolved with the total supply of tokens.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.erc20.balanceOf(props)\n\nReturns Promise that will be resolved with the balance of owner address\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * owner: Address to check balance\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.erc20.transfer(props)\n\nTransfers tokens. Returns Promise that will be resolved with the hash of created contract transaction\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * privateKey: Private key (64 hex symbols, without '0x' prefix)\n  * to: Address of the transaction receiver\n  * value: Transaction value\n  * gasLimit: (optional) Gas limit for the transaction\n  * gasPrice: (optional) Gas price for the transaction\n  * nonce: (optional) Nonce for the transaction\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.erc20.allEvents(props)\n\nSubscribes to all contract events. Returns Promise that will be resolved with the event emitter.\n\nThe event emitter has the following events:\n  * `data`: Fires on each incoming event with the event object as argument\n  * `error`: Fires when an error in the subscription occours\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * options: (optional) Event options\n    * filter: (optional) Filter options by indexed event parameters\n    * fromBlock: (optional) The number of the earliest block\n    * toBlock: (optional) The number of the latest block\n    * address: (optional) An address(es) to get logs from\n    * topics: (optional) Allows to manually set the topics for the event filter\n  * callback: (optional) Callback which fired for each event or error\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.erc20.Transfer(props)\n\nSubscribes to Transfer event. Returns Promise that will be resolved with the event emitter (the same as for [allEvents](#contractserc20alleventsprops)).\n\n##### props\n\nThe same as for [allEvents](#props-6)\n\n#### contracts.erc20.getPastEvents(props)\n\nReturns Promise that will be resolved with the past event logs.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * event: optional Event name\n  * options: (optional) The same options as for [allEvents](#props-6)\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.erc20.estimateGas(props)\n\nReturns Promise that will be resolved with estimate gas value.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * from: Transaction sender address\n  * method: Method name\n  * args: Method arguments\n  * ssl: (optional) Defines using of ssl for connection or not\n\n### `ERC20Mintable` API\n\n#### contracts.erc20Mintable.allEvents(props)\n\nSee [contracts.erc20.allEvents](#contractserc20alleventsprops)\n\n#### contracts.erc20Mintable.MintEvent(props)\n\nSubscribes to MintEvent event. Returns Promise that will be resolved with the event emitter (the same as for [allEvents](#contractserc20mintablealleventsprops)).\n\n#### contracts.erc20Mintable.BurnEvent(props)\n\nSubscribes to BurnEvent event. Returns Promise that will be resolved with the event emitter (the same as for [allEvents](#contractserc20mintablealleventsprops)).\n\n#### contracts.erc20Mintable.getPastEvents(props)\n\nSee [contracts.erc20.getPastEvents](#contractserc20getpasteventsprops)\n\n### `ERC20Named` API\n\n#### contracts.erc20Named.name(props)\n\nReturns Promise that will be resolved with the token name.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.erc20Named.symbol(props)\n\nReturns Promise that will be resolved with the token symbol.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.erc20Named.decimals(props)\n\nReturns Promise that will be resolved with token decimals.\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * ssl: (optional) Defines using of ssl for connection or not\n\n### `Controller` API\n\n#### contracts.controller.mint(props)\n\nMint tokens. Returns Promise that will be resolved with the hash of created contract transaction\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * privateKey: Private key (64 hex symbols, without '0x' prefix)\n  * account: Address of account to mint tokens to\n  * value: Transaction value\n  * gasLimit: (optional) Gas limit for the transaction\n  * gasPrice: (optional) Gas price for the transaction\n  * nonce: (optional) Nonce for the transaction\n  * ssl: (optional) Defines using of ssl for connection or not\n\n#### contracts.controller.burn(props)\n\nBurn tokens. Returns Promise that will be resolved with the hash of created contract transaction\n\n##### props\n\n  * rpcaddr: RPC address of Ethereum node to connect on\n  * rpcport: RPC port of Ethereum node to connect on\n  * contractAddress: Contract address\n  * privateKey: Private key (64 hex symbols, without '0x' prefix)\n  * account: Address of account to burn tokens from\n  * value: Transaction value\n  * gasLimit: (optional) Gas limit for the transaction\n  * gasPrice: (optional) Gas price for the transaction\n  * nonce: (optional) Nonce for the transaction\n  * ssl: (optional) Defines using of ssl for connection or not\n\n### getAddressFromPrivateKey(privateKey)\n\nGets account's address from its private key.\n\n  * privateKey: Private key (64 hex symbols, without '0x' prefix)\n\n## Testing\n\nTestrpc should be launched before tests.\nAlso `JSON_PATH` env variable should exists. `JSON_PATH` stores path to .json file, that contains:\n\n  * account addresses\n  * private keys\n  * contract addresses\n\nThe simplest way to `test` - is launch jibrel-contracts tests. During tests execution it will check that jibrel-contracts-jsapi project is in the same dir, and will agregate all need information and write it to .json file.\n\n### Steps to launch tests from jibrel-contracts\n\n**Note**: prepare jibrel-contracts-jsapi project (`npm i \u0026\u0026 npm run compile`)\n\n```\n$ git clone git@github.com:jibrelnetwork/jibrel-contracts.git\n$ cd jibrel-contracts\n$ git pull origin master\n$ git reset --hard e3c917eadcabddef00ab3acd45791c1c456787dd\n$ npm i\n$ npm run compile\n$ npm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjibrelnetwork%2Fjibrel-contracts-jsapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjibrelnetwork%2Fjibrel-contracts-jsapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjibrelnetwork%2Fjibrel-contracts-jsapi/lists"}