{"id":15290528,"url":"https://github.com/bepronetwork/bepro-js","last_synced_at":"2025-04-07T10:26:29.089Z","repository":{"id":40575905,"uuid":"323182812","full_name":"bepronetwork/bepro-js","owner":"bepronetwork","description":"The repository contains a comprehensive documentation of the bepro.network ecosystem as a javascript framework. If you are new to BEPRO, you might want to check out the Website Overview or our public \"Start Building\" Page.","archived":false,"fork":false,"pushed_at":"2024-03-23T05:52:08.000Z","size":43104,"stargazers_count":164,"open_issues_count":38,"forks_count":94,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-31T08:09:44.675Z","etag":null,"topics":["bepro","bepro-js","javascript","npm","solidity"],"latest_commit_sha":null,"homepage":"","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/bepronetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-20T23:09:24.000Z","updated_at":"2025-02-25T18:52:45.000Z","dependencies_parsed_at":"2024-06-20T19:07:21.790Z","dependency_job_id":"e67a438d-f222-4a68-94ef-cfe7e39a5778","html_url":"https://github.com/bepronetwork/bepro-js","commit_stats":{"total_commits":522,"total_committers":16,"mean_commits":32.625,"dds":0.4444444444444444,"last_synced_commit":"4462215ddf76166c06c6807a09cc0093149d4d53"},"previous_names":["betprotocol/bepro-js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bepronetwork%2Fbepro-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bepronetwork%2Fbepro-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bepronetwork%2Fbepro-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bepronetwork%2Fbepro-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bepronetwork","download_url":"https://codeload.github.com/bepronetwork/bepro-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247634208,"owners_count":20970484,"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":["bepro","bepro-js","javascript","npm","solidity"],"created_at":"2024-09-30T16:08:31.181Z","updated_at":"2025-04-07T10:26:29.070Z","avatar_url":"https://github.com/bepronetwork.png","language":"JavaScript","readme":"# ![alt tag](https://uploads-ssl.webflow.com/5fc917a7914bf7aa30cae033/5ff4e84c73f45881c8b9cd85_Logo-purple-dark-background-p-500.png)\n\n![Python](https://img.shields.io/badge/python-v2.7+-blue.svg)\n![Build Status](https://github.com/bepronetwork/bepro-js/actions/workflows/build.yml/badge.svg)\n![Dependencies](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen.svg)\n[![GitHub issues](https://img.shields.io/github/issues/bepronetwork/bepro-js.svg)](https://GitHub.com/bepronetwork/bepro-js/issues/)\n![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n## Introductions\n\nBuild the future of DeFi Gaming\n\n## Installation\n\nbepro-js is available as [npm package](https://www.npmjs.com/package/bepro-js).\n\n```bash\n# with npm\nnpm i bepro-js\n\n# with yarn\nyarn add bepro-js\n```\n\n## Local Development\n\n### Requirements\n\n\u003cdetails\u003e\n  \u003csummary\u003ePython 2\u003c/summary\u003e\n\n  For Linux:\n  ```bash\n  # Install it via bash terminal globally\n  sudo apt install python2\n\n  # Check the installed version.\n  # Must shown Python 2.7.18rc1 on terminal to the install be OK\n  python2 --version\n\n  # Verify Python 2.7 path\n  ls /usr/bin/python*\n\n  # Set Python 2 as alternative 1\n  sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1\n\n  # Confirm Python 2 as alternative priority 1\n  sudo update-alternatives --config python\n\n  # On the working directory, run the cmd below to set Python locally\n  npm config set python python\n\n  # Confirm the procedure.\n  # Must show valid Python version on terminal if OK\n  python --version\n  ```\n\n  For other systems please follow the appropriate steps.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eNode.js 16\u003c/summary\u003e\n\n  Install via NVM:\n  ```bash\n  # Install NVM\n  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash\n\n  # Install recommended Node.js version for bepro-js\n  nvm install lts/gallium\n\n  # Set it on the working directory\n  nvm alias default lts/gallium\n\n  # Use the settled as default\n  nvm use default\n\n  # Confirm the procedure.\n  # Must show valid Node-js version on terminal if OK\n  node --version\n  ```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eYarn 1\u003c/summary\u003e\n\n  ```bash\n  npm install -g yarn\n  ```\n\n  Or check [alternative install methods](https://classic.yarnpkg.com/en/docs/install).\n\u003c/details\u003e\n\n### Running commands\n\nThe following is a set of the commands you most likely will need. For details on these or to check all relevant Node.js tasks, please reference the `scripts` section of *package.json*.\n\n```bash\n# Install and update dependencies\nyarn\n\n# Start watch for rebuild on file changes\nyarn start\n\n# Build from src\nyarn build\n```\n\n## Local Ethereum Client\n\nFor tests, we use [Ganache](https://trufflesuite.com/ganache/).\n\nOnce installed, you can:\n\n```bash\n# Boot it up\nyarn ganache:start\n\n# Run the tests\nyarn test\n```\n\n## Docker support\n\n### Requirements\n\n\u003cdetails\u003e\n  \u003csummary\u003eDocker 19.03.3+\u003c/summary\u003e\n\n  ```shell script\n  sudo curl -fsSL get.docker.com -o get-docker.sh \u0026\u0026 sh get-docker.sh\n  ```\n\n  **Notice**: If you already have Docker installed, this script can cause trouble. If you installed the current Docker package using this script, run it again to update Docker.\n\n  Or use official installation instructions: [Mac](https://docs.docker.com/docker-for-mac/install/), [Windows](https://docs.docker.com/docker-for-windows/install/), [Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/), [Other](https://docs.docker.com/install/#supported-platforms).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eDocker Compose 1.19.0+\u003c/summary\u003e\n\n  ```shell script\n  sudo curl -L \"https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose \u0026\u0026 sudo chmod +x /usr/local/bin/docker-compose\n  ```\n\n  For Mac or Windows take a look on: [official guides](https://docs.docker.com/compose/install/#install-compose).\n\u003c/details\u003e\n\n\n### Running containers\n\nYou can use docker-compose directly, or the nifty `make` that comes bundled.\n\n```bash\n# Build images\nmake build\n\n# Starting containers in background:\nmake up\n\n# Start npm watch:\nmake watch\n\n# Run tests\nmake test\n\n# Stop containers\nmake down\n\n# Using docker-compose instead of make\ndocker-compose up\n```\n\n## Documentation\n\nFull API docs can be found at https://bepronetwork.github.io/bepro-js/\n\n## Usage\n\n### Initialization\n\n#### Via WEB3_LINK from any Web3 Provider\n\nNote: `WEB3_LINK` should be get from Infura/Quicknode or any other Web3 Provider - ETH, BSC, Moonbeam and others are supported\n\n```javascript\nimport {\n    Application, DexStorage, ERC20Contract, StakingContract,\n    ERC20TokenLock, ERC721Collectibles, ERC721Standard\n} from 'bepro-js';\n\n/* 1.1 - Instantiate the App for Metamask functionality (MAINNET) */\nconst app = new Application({\n  opt: { web3Connection: 'WEB3_LINK' },\n});\n\n/* 1.2 - Instantiate StakingContract Object or any other in a similar way (Staking, ERC20 etc..) */\n// - MAINNET\nconst staking = new StakingContract({\n  contractAddress: null, /* Contract Address (optional) */\n  opt: { web3Connection: 'WEB3_LINK' },\n});\n\n// - TEST net e.g. Rinkeby\nconst stakingTest = new StakingContract({\n  test: true,\n  contractAddress: null, /* Contract Address (optional) */\n});\n\n/* 2 - Connect the App/Contract to the Metamask Web3 Injected wallet*/\nawait app.login();\nawait staking.login();\n/* or instantiate with the provided web3Connection, for tests it was already done at object creation */\nawait app.start();\nawait staking.start();\n```\n\n#### Via leveraged Web3 Provider\n\nApplication can be initialized with a web3 provider directly, but all connection login is assumed to be on the consumer side in this case; i.e. no need to call start() or login(), that logic should be handled separately within the provider itself or by the consumer.\n\n```javascript\n// Use Metamask's provider, could be any other compatible Web3 Provider object from any other lib\nconst app = new Application({\n  opt: { provider: window.ethereum },\n});\n```\n\n### Asserting and Deploying contracts\n\n```javascript\n/* 4 - Assert all object data */\nawait staking.__assert();\nawait stakingTest.__assert();\n/* or deploy the contract*/\nawait staking.deploy();\nawait stakingTest.deploy();\n```\n\n### Accessing methods\n\n```javascript\n/* 5 - Access other Methods */\nawait staking.availableTokens();\nawait stakingTest.availableTokens();\n```\n\n### Transaction options\n\nMost contract `send` methods (those that act on and potentially alter the state of the blockchain) can be passed an optional argument, taking the form of an object with several properties that control the transaction.\n\n\u003cdetails\u003e\n  \u003csummary\u003e__sendTx() details for internal development\u003c/summary\u003e\n\n  #### `call` instead of `send`\n\n  If you send a truthy property `call`, you are signaling that this transaction is a read-only call to the blockchain, and will thus not incur in any gas fees, value transaction, or even needs to be signed by a specific account.\n\n  ```javascript\n  await this.__sendTx(\n    this.getContract().methods.someMethod(),\n    { call: true },\n  );\n  ```\n\n  #### `value`\n\n  Likewise to above, if a transaction is to have an intrinsic value, this is also passed through this object.\n\n  ```javascript\n  await this.__sendTx(\n    this.getContract().methods.someMethod(),\n    { value: someValue },\n  );\n  ```\n\u003c/details\u003e\n\n#### Gas Fees\n\nTransaction fees are automatically calculated via web3's own estimation methods.\n\nIn order to overestimate and avoid out-of-gas transaction errors if necessary, we can pass a second argument with certain parameters to most Contract methods that involve `send` transactions (those requiring gas):\n\n```javascript\nawait staking.subscribeProduct(\n  { address, product_id, amount },\n  {\n    gasAmount: 201654, // override the estimated gas fee for this method\n    gasFactor: 1.2, // applied to every calculated or given gas amount, including the gasAmount from this object if passed\n    gasPrice: '5000000000', // override the network's default gas price\n  },\n);\n```\n\nIn particular, `gasFactor` is a parameter that can be passed when instantiating the contract, so that gas estimations for every method called on that contract instance will have that factor applied:\n\n```javascript\nconst staking = new StakingContract({\n  contractAddress,\n  gasFactor: 1.25 // default 1\n  opt: { provider },\n});\n\n// The following will have a gasFactor of 1.25\nawait staking.subscribeProduct({ address, product_id, amount });\n\n// We can still override it per-method, and pass other parameters as well.\nawait staking.subscribeProduct(\n  { address, product_id, amount },\n  {\n    gasAmount: 201654,\n    gasFactor: 1.2,\n  },\n);\n```\n\nEstimated gas fees leverage the following web3 functionalities:\n- [chain's getGasPrice()](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#getgasprice)\n- [contract method's estimateGas()](https://web3js.readthedocs.io/en/v1.2.11/web3-eth-contract.html?highlight=estimateGas#methods-mymethod-estimategas)\n\n#### Transaction signer\n\nYou can get all accounts (wallet addressed) managed by the current wallet provider through:\n\n```javascript\nawait app.getAccounts();\n// =\u003e [ '0xAbA...', '0xCdD...', '0xEfE...', ... ]\n```\n\nBy default all transactions will be signed by the first account, which is considered currently active. Any transaction on any contract, including deployment, can be signed by any of the connected accounts:\n\n```javascript\nawait staking.deploy({ from: '0xCdC...' });\n\nawait staking.subscribeProduct(\n  { address, product_id, amount },\n  { from: '0xCdC...' },\n);\n```\n\n## Contribution\n\nContributions are welcomed but we ask to read existing code guidelines, especially for the code format. Please review [Contributor guidelines][1]\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n## Notes\n\nThe usage of `ETH` in all methods or params means using the native currency of that blockchain, example `BSC` in Binance Chain would still be nominated as `ETH`\n\n[1]: https://github.com/bepronetwork/bepro-js/blob/master/CONTRIBUTING.md\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbepronetwork%2Fbepro-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbepronetwork%2Fbepro-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbepronetwork%2Fbepro-js/lists"}