├── .gitattributes ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── contract └── bep20-token.sol ├── demo └── example.js ├── frontend ├── .eslintcache ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── logo.svg │ ├── pages │ ├── BnbBalance.js │ ├── CreateWallet.js │ ├── ImportWallet.js │ ├── SendBnb.js │ ├── SendToken.js │ └── TokenBalance.js │ ├── reportWebVitals.js │ └── setupTests.js ├── package-lock.json ├── package.json ├── server.js └── src ├── bep20ABI.json └── centerpirme.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # node_modules 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "git.ignoreLimitWarning": true 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Binance SmartChain NodeJS SDK 2 | 3 | ## Prerequisites 4 | 5 | This project requires NodeJS (version 8 or later) and NPM. 6 | [Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install. 7 | To make sure you have them available on your machine, 8 | try running the following command. 9 | 10 | ```sh 11 | $ npm -v && node -v 12 | 6.4.1 13 | v8.16.0 14 | ``` 15 | 16 | ## Table of contents 17 | 18 | - [Project Name](#project-name) 19 | - [Prerequisites](#prerequisites) 20 | - [Table of contents](#table-of-contents) 21 | - [Getting Started](#getting-started) 22 | - [Installation](#installation) 23 | - [API](#api) 24 | - [Create Wallet](#createwallet) 25 | - [Import Wallet](#importwallet) 26 | - [Keystore](#keystore) 27 | - [Private Key](#keystore) 28 | - [Balance](#balance) 29 | - [BNB Balance](#etherbalance) 30 | - [BEP20 Token Balance](#erc20tokenbalance) 31 | - [Send](#send) 32 | - [Send BNB](#sendether) 33 | - [Send BEP20 Token](#senderc20token) 34 | - [Demo](#demo) 35 | 36 | ## Getting Started 37 | 38 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. 39 | 40 | ## Installation 41 | 42 | **BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites) 43 | 44 | Start with cloning this repo on your local machine: 45 | 46 | ```sh 47 | $ git clone https://github.com/centerprime/Node-Binance-SDK.git 48 | ``` 49 | 50 | To install and set up the library, run: 51 | 52 | ```sh 53 | $ npm install node-binance-sdk 54 | ``` 55 | 56 | ## API 57 | 58 | ### Create Wallet 59 | 60 | ```js 61 | import BnbManager from "../src/centerprime.js"; 62 | 63 | var bnbManager = new BnbManager("Infura Url"); 64 | bnbManager.createAccount("12345") 65 | .then(res => { 66 | console.log(res); 67 | }); 68 | ``` 69 | 70 | 71 | ### Import Wallet by Keystore 72 | 73 | ```js 74 | import BnbManager from "../src/centerprime.js"; 75 | 76 | var bnbManager = new BnbManager("Infura Url"); 77 | let keystore = {}; 78 | let password = ''; 79 | bnbManager.importWalletByKeystore(keystore,password) 80 | .then(res => { 81 | console.log(res); 82 | }); 83 | ``` 84 | 85 | ### Import Wallet by Private key 86 | 87 | ```js 88 | import BnbManager from "../src/centerprimeSDK.js"; 89 | 90 | var bnbManager = new BnbManager("Infura Url"); 91 | let privateKey = ''; 92 | bnbManager.importWalletByPrivateKey(privateKey) 93 | .then(res => { 94 | console.log(res); 95 | }); 96 | ``` 97 | 98 | ### Get BNB balance 99 | 100 | ```js 101 | import BnbManager from "../src/centerprimeSDK.js"; 102 | 103 | var bnbManager = new BnbManager("Infura Url"); 104 | let address = ''; 105 | bnbManager.getBnbBalance(address) 106 | .then(res => { 107 | console.log(res); 108 | }); 109 | ``` 110 | 111 | 112 | ### Get BEP20 token balance 113 | 114 | ```js 115 | import BnbManager from "../src/centerprimeSDK.js"; 116 | 117 | var bnbManager = new BnbManager("Infura Url"); 118 | let tokenContractAddress = ''; 119 | let address = ''; 120 | bnbManager.getBEPTokenBalance(tokenContractAddress, address) 121 | .then(res => { 122 | console.log(res); 123 | }); 124 | ``` 125 | 126 | ### Send BEP20 token 127 | 128 | ```js 129 | import BnbManager from "../src/centerprimeSDK.js"; 130 | 131 | var bnbManager = new BnbManager("Infura Url"); 132 | let keystore = {}; 133 | let password = ''; 134 | let tokenContractAddress = ''; 135 | let toAddress = ''; 136 | let amount = ''; 137 | let chainId = ''; // 1 : Mainnet 3 : Ropsten 138 | bnbManager.sendToken(keystore, password, tokenContractAddress , toAddress , amount , chainId) 139 | .then(res => { 140 | console.log(res); 141 | }); 142 | ``` 143 | 144 | 145 | ### Send BNB 146 | 147 | ```js 148 | import BnbManager from "../src/centerprimeSDK.js"; 149 | 150 | var bnbManager = new BnbManager("Infura Url"); 151 | let keystore = {}; 152 | let password = ''; 153 | let toAddress = ''; 154 | let amount = ''; 155 | let chainId = ''; // 1 : Mainnet 3 : Ropsten 156 | bnbManager.sendBNB(keystore, password , toAddress , amount , chainId) 157 | .then(res => { 158 | console.log(res); 159 | }); 160 | ``` 161 | 162 | ### Demo 163 | 164 | First run backend 165 | 166 | ```js 167 | npm install 168 | npm start 169 | ``` 170 | 171 | Second run frontend /frontend/ 172 | 173 | ```js 174 | npm install 175 | npm start 176 | ``` -------------------------------------------------------------------------------- /contract/bep20-token.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.24; 2 | 3 | 4 | // ---------------------------------------------------------------------------- 5 | // Lib: Safe Math 6 | // ---------------------------------------------------------------------------- 7 | contract SafeMath { 8 | 9 | function safeAdd(uint a, uint b) public pure returns (uint c) { 10 | c = a + b; 11 | require(c >= a); 12 | } 13 | 14 | function safeSub(uint a, uint b) public pure returns (uint c) { 15 | require(b <= a); 16 | c = a - b; 17 | } 18 | 19 | function safeMul(uint a, uint b) public pure returns (uint c) { 20 | c = a * b; 21 | require(a == 0 || c / a == b); 22 | } 23 | 24 | function safeDiv(uint a, uint b) public pure returns (uint c) { 25 | require(b > 0); 26 | c = a / b; 27 | } 28 | } 29 | 30 | 31 | contract BEP20Interface { 32 | function totalSupply() public constant returns (uint); 33 | function balanceOf(address tokenOwner) public constant returns (uint balance); 34 | function allowance(address tokenOwner, address spender) public constant returns (uint remaining); 35 | function transfer(address to, uint tokens) public returns (bool success); 36 | function approve(address spender, uint tokens) public returns (bool success); 37 | function transferFrom(address from, address to, uint tokens) public returns (bool success); 38 | 39 | event Transfer(address indexed from, address indexed to, uint tokens); 40 | event Approval(address indexed tokenOwner, address indexed spender, uint tokens); 41 | } 42 | 43 | 44 | /** 45 | Contract function to receive approval and execute function in one call 46 | 47 | Borrowed from MiniMeToken 48 | */ 49 | contract ApproveAndCallFallBack { 50 | function receiveApproval(address from, uint256 tokens, address token, bytes data) public; 51 | } 52 | 53 | /** 54 | BEP20 Token, with the addition of symbol, name and decimals and assisted token transfers 55 | */ 56 | contract SampleToken is BEP20Interface, SafeMath { 57 | string public symbol; 58 | string public name; 59 | uint8 public decimals; 60 | uint public _totalSupply; 61 | 62 | mapping(address => uint) balances; 63 | mapping(address => mapping(address => uint)) allowed; 64 | 65 | 66 | // ------------------------------------------------------------------------ 67 | // Constructor 68 | // ------------------------------------------------------------------------ 69 | constructor() public { 70 | symbol = "Sample"; 71 | name = "Sample Token"; 72 | decimals = 2; 73 | _totalSupply = 100000; 74 | balances[msg.sender] = _totalSupply; 75 | emit Transfer(address(0), msg.sender, _totalSupply); 76 | } 77 | 78 | 79 | // ------------------------------------------------------------------------ 80 | // Total supply 81 | // ------------------------------------------------------------------------ 82 | function totalSupply() public constant returns (uint) { 83 | return _totalSupply - balances[address(0)]; 84 | } 85 | 86 | 87 | // ------------------------------------------------------------------------ 88 | // Get the token balance for account tokenOwner 89 | // ------------------------------------------------------------------------ 90 | function balanceOf(address tokenOwner) public constant returns (uint balance) { 91 | return balances[tokenOwner]; 92 | } 93 | 94 | 95 | // ------------------------------------------------------------------------ 96 | // Transfer the balance from token owner's account to to account 97 | // - Owner's account must have sufficient balance to transfer 98 | // - 0 value transfers are allowed 99 | // ------------------------------------------------------------------------ 100 | function transfer(address to, uint tokens) public returns (bool success) { 101 | balances[msg.sender] = safeSub(balances[msg.sender], tokens); 102 | balances[to] = safeAdd(balances[to], tokens); 103 | emit Transfer(msg.sender, to, tokens); 104 | return true; 105 | } 106 | 107 | 108 | // ------------------------------------------------------------------------ 109 | // Token owner can approve for spender to transferFrom(...) tokens 110 | // from the token owner's account 111 | // 112 | // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md 113 | // recommends that there are no checks for the approval double-spend attack 114 | // as this should be implemented in user interfaces 115 | // ------------------------------------------------------------------------ 116 | function approve(address spender, uint tokens) public returns (bool success) { 117 | allowed[msg.sender][spender] = tokens; 118 | emit Approval(msg.sender, spender, tokens); 119 | return true; 120 | } 121 | 122 | 123 | // ------------------------------------------------------------------------ 124 | // Transfer tokens from the from account to the to account 125 | // 126 | // The calling account must already have sufficient tokens approve(...)-d 127 | // for spending from the from account and 128 | // - From account must have sufficient balance to transfer 129 | // - Spender must have sufficient allowance to transfer 130 | // - 0 value transfers are allowed 131 | // ------------------------------------------------------------------------ 132 | function transferFrom(address from, address to, uint tokens) public returns (bool success) { 133 | balances[from] = safeSub(balances[from], tokens); 134 | allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); 135 | balances[to] = safeAdd(balances[to], tokens); 136 | emit Transfer(from, to, tokens); 137 | return true; 138 | } 139 | 140 | 141 | // ------------------------------------------------------------------------ 142 | // Returns the amount of tokens approved by the owner that can be 143 | // transferred to the spender's account 144 | // ------------------------------------------------------------------------ 145 | function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { 146 | return allowed[tokenOwner][spender]; 147 | } 148 | 149 | 150 | // ------------------------------------------------------------------------ 151 | // Token owner can approve for spender to transferFrom(...) tokens 152 | // from the token owner's account. The spender contract function 153 | // receiveApproval(...) is then executed 154 | // ------------------------------------------------------------------------ 155 | function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { 156 | allowed[msg.sender][spender] = tokens; 157 | emit Approval(msg.sender, spender, tokens); 158 | ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); 159 | return true; 160 | } 161 | 162 | 163 | // ------------------------------------------------------------------------ 164 | // Don't accept ETH 165 | // ------------------------------------------------------------------------ 166 | function () public payable { 167 | revert(); 168 | } 169 | } -------------------------------------------------------------------------------- /demo/example.js: -------------------------------------------------------------------------------- 1 | import BnbManager from "../src/centerpirme.js"; 2 | 3 | var bnbManager = new BnbManager("https://data-seed-prebsc-1-s1.binance.org:8545"); 4 | bnbManager.getBEPTokenBalance("0x6ce8da28e2f864420840cf74474eff5fd80e65b8","0x082a2027dc16f42d6e69be8fa13c94c17c910ebe").then( 5 | res=>{ 6 | console.log(res); 7 | }, error=>{ 8 | console.log(error); 9 | } 10 | ); 11 | 12 | 13 | let keystore = {}; 14 | let password = ""; 15 | let amount = 12 16 | let toAddress = '0x38C1E1204C10C8be90ecA671Da8Ea8a9AEb16031' 17 | 18 | 19 | let tokenContractAddress = '0xa1825717848bdeb9b1b2389471fe0d98c0af71a5'; 20 | 21 | bnbManager.sendToken(keystore,password,tokenContractAddress, toAddress,amount,3).then(res=>{ 22 | console.log(res); 23 | }) -------------------------------------------------------------------------------- /frontend/.eslintcache: -------------------------------------------------------------------------------- 1 | [{"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/index.js":"1","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/reportWebVitals.js":"2","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/App.js":"3","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/CreateWallet.js":"4","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/BnbBalance.js":"5","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/SendToken.js":"6","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/ImportWallet.js":"7","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/SendBnb.js":"8","/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/TokenBalance.js":"9"},{"size":449,"mtime":1610073016409,"results":"10","hashOfConfig":"11"},{"size":362,"mtime":1610073016410,"results":"12","hashOfConfig":"11"},{"size":1641,"mtime":1610073016408,"results":"13","hashOfConfig":"11"},{"size":1536,"mtime":1610073016409,"results":"14","hashOfConfig":"11"},{"size":1520,"mtime":1610073016409,"results":"15","hashOfConfig":"11"},{"size":2610,"mtime":1610073016410,"results":"16","hashOfConfig":"11"},{"size":1808,"mtime":1610073016409,"results":"17","hashOfConfig":"11"},{"size":2238,"mtime":1610073016409,"results":"18","hashOfConfig":"11"},{"size":1798,"mtime":1610089350806,"results":"19","hashOfConfig":"11"},{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1s6tb0n",{"filePath":"22","messages":"23","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"24","messages":"25","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"26","messages":"27","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"28","messages":"29","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"32","messages":"33","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"34","messages":"35","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"36","messages":"37","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/index.js",[],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/reportWebVitals.js",[],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/App.js",["38"],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/CreateWallet.js",["39"],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/BnbBalance.js",[],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/SendToken.js",[],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/ImportWallet.js",["40","41"],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/SendBnb.js",[],"/Users/htnteam/IdeaProjects/NodeProjects/bnb/BinanceSmartChain-NodeJS-SDK/frontend/src/pages/TokenBalance.js",[],{"ruleId":"42","severity":1,"message":"43","line":1,"column":8,"nodeType":"44","messageId":"45","endLine":1,"endColumn":12},{"ruleId":"42","severity":1,"message":"46","line":10,"column":12,"nodeType":"44","messageId":"45","endLine":10,"endColumn":17},{"ruleId":"42","severity":1,"message":"47","line":12,"column":12,"nodeType":"44","messageId":"45","endLine":12,"endColumn":18},{"ruleId":"42","severity":1,"message":"48","line":12,"column":20,"nodeType":"44","messageId":"45","endLine":12,"endColumn":29},"no-unused-vars","'logo' is defined but never used.","Identifier","unusedVar","'error' is assigned a value but never used.","'result' is assigned a value but never used.","'setResult' is assigned a value but never used."] -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /frontend/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.8", 7 | "@testing-library/react": "^11.2.2", 8 | "@testing-library/user-event": "^12.6.0", 9 | "react": "^17.0.1", 10 | "react-dom": "^17.0.1", 11 | "react-router-dom": "^5.2.0", 12 | "react-scripts": "4.0.1", 13 | "web-vitals": "^0.2.4" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": [ 23 | "react-app", 24 | "react-app/jest" 25 | ] 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centerprime/BinanceSmartChain-NodeJS-SDK/c95fea0215fab83f09753af6477583bf231568a0/frontend/public/favicon.ico -------------------------------------------------------------------------------- /frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /frontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centerprime/BinanceSmartChain-NodeJS-SDK/c95fea0215fab83f09753af6477583bf231568a0/frontend/public/logo192.png -------------------------------------------------------------------------------- /frontend/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centerprime/BinanceSmartChain-NodeJS-SDK/c95fea0215fab83f09753af6477583bf231568a0/frontend/public/logo512.png -------------------------------------------------------------------------------- /frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /frontend/src/App.js: -------------------------------------------------------------------------------- 1 | import logo from './logo.svg'; 2 | import './App.css'; 3 | import { BrowserRouter, Switch, Route, NavLink } from 'react-router-dom'; 4 | import CreateWallet from './pages/CreateWallet'; 5 | import ImportWallet from './pages/ImportWallet'; 6 | import BnbBalance from './pages/BnbBalance'; 7 | import TokenBalance from './pages/TokenBalance'; 8 | import SendBnb from './pages/SendBnb'; 9 | import SendToken from './pages/SendToken'; 10 | 11 | function App() { 12 | return ( 13 |
14 | 15 |
16 |
17 | Create Wallet 18 | Import Wallet 19 | Bnb Balance 20 | Token Balance 21 | Send Bnb 22 | Send Token 23 |
24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 |
35 |
36 |
37 | ); 38 | } 39 | 40 | export default App; 41 | -------------------------------------------------------------------------------- /frontend/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 12 | monospace; 13 | } 14 | 15 | .content { 16 | padding: 20px; 17 | } 18 | 19 | .header { 20 | padding: 10px; 21 | background: #edf2f4; 22 | border-bottom: 1px solid #999; 23 | } 24 | .header a { 25 | color: #0072ff; 26 | text-decoration: none; 27 | margin-left: 20px; 28 | margin-right: 5px; 29 | } 30 | .header a:hover { 31 | color: #8a0f53; 32 | } 33 | .header small { 34 | color: #666; 35 | } 36 | .header .active { 37 | color: #2c7613; 38 | } -------------------------------------------------------------------------------- /frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want to start measuring performance in your app, pass a function 10 | // to log results (for example: reportWebVitals(console.log)) 11 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 12 | reportWebVitals(); 13 | -------------------------------------------------------------------------------- /frontend/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/src/pages/BnbBalance.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from 'react'; 2 | import axios from 'axios'; 3 | 4 | 5 | function BnbBalance() { 6 | 7 | 8 | const [loading, setLoading] = useState(false); 9 | const address = useFormInput(''); 10 | const [error, setError] = useState(null); 11 | 12 | // handle button click of login form 13 | const handleLogin = () => { 14 | setError(null); 15 | setLoading(true); 16 | let addressTxt = address.value; 17 | if(addressTxt === ''){ 18 | setLoading(false); 19 | setError("Please fill the fileds"); 20 | } else { 21 | axios.post('http://localhost:3080/api/bnbBalance', { address: address.value }).then(response => { 22 | console.log(JSON.stringify(response.data)); 23 | setLoading(false); 24 | setError(response.data) 25 | }).catch(error => { 26 | setLoading(false); 27 | if (error.response.status === 401) setError(error.response.data.message); 28 | else setError("Something went wrong. Please try again later."); 29 | }); 30 | } 31 | 32 | } 33 | 34 | 35 | return ( 36 |
37 |
38 | Address
39 |
40 | 41 |
42 |
43 |

44 |

{error}

45 |
46 | ); 47 | } 48 | 49 | const useFormInput = initialValue => { 50 | const [value, setValue] = useState(initialValue); 51 | 52 | const handleChange = e => { 53 | setValue(e.target.value); 54 | } 55 | return { 56 | value, 57 | onChange: handleChange 58 | } 59 | } 60 | 61 | export default BnbBalance; -------------------------------------------------------------------------------- /frontend/src/pages/CreateWallet.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from 'react'; 2 | import axios from 'axios'; 3 | 4 | 5 | function Home() { 6 | 7 | 8 | const [loading, setLoading] = useState(false); 9 | const password = useFormInput(''); 10 | const [error, setError] = useState(null); 11 | const [keystore, setKeystore] = useState(null); 12 | 13 | // handle button click of login form 14 | const handleLogin = () => { 15 | setError(null); 16 | setLoading(true); 17 | axios.post('http://localhost:3080/api/createWallet', { password: password.value }).then(response => { 18 | console.log(JSON.stringify(response.data)); 19 | setKeystore(JSON.stringify(response.data.keystore)); 20 | setLoading(false); 21 | }).catch(error => { 22 | setLoading(false); 23 | if (error.response.status === 401) setError(error.response.data.message); 24 | else setError("Something went wrong. Please try again later."); 25 | }); 26 | } 27 | 28 | 29 | return ( 30 |
31 | Create Wallet

32 |
33 | Password
34 | 35 |
36 |
37 |

38 | Keystore
39 |