forked from bnb-chain/bnb-chain-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d88325f
commit 183dcf8
Showing
20 changed files
with
160,719 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Truffle | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# BSC Hello World Tutorial | ||
|
||
## Overview | ||
|
||
## Prerequisites | ||
- node --version | ||
- v16.13.0 | ||
- npm --version | ||
- 8.1.0 | ||
- truffle version | ||
- Truffle v5.5.19 (core: 5.5.19) | ||
- Ganache v7.2.0 | ||
- Solidity - ^0.8.0 (solc-js) | ||
- Web3.js v1.5.3 | ||
- MetaMask Wallet | ||
- 10.16.1 | ||
|
||
## Setup | ||
|
||
1. **Clone the repository** | ||
```gh repo clone RumeelHussainbnb/BSC-Hello-World-Tutorial``` | ||
2. **Change the current directory** | ||
```cd BSC-Hello-World-Tutorial``` | ||
3. **Install all the dependencies (node modules)** | ||
```npm install``` | ||
4. Create a ```.secret``` file with the secret phrase of MetaMask. Refer [here](https://metamask.zendesk.com/hc/en-us/articles/360015290032-How-to-reveal-your-Secret-Recovery-Phrase) for details on how to get MetaMask secret phrase. | ||
5. **Compile Smart Contracts** | ||
```truffle compile``` | ||
6. **Migrate Smart Contracts** | ||
```truffle migrate --reset --network bscTestnet``` | ||
7. **Create build** | ||
```npm run build``` | ||
8. **Run the application** ```npm run dev``` | ||
|
||
>**Note:** _Make Sure Nothing is Running on localhost:3000_ | ||
## Available Scripts | ||
``` | ||
$ truffle compile | ||
$ truffle migrate | ||
$ truffle test | ||
$ npm run build | ||
$ npm run dev | ||
``` | ||
|
||
## Structure | ||
```sh | ||
HelloWorld. | ||
| .env | ||
| .gitattributes | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| truffle-config.js | ||
| webpack.config.js | ||
| yarn.lock | ||
| | ||
+---build | ||
| \---contracts | ||
| HelloWorld.json | ||
| Migrations.json | ||
| | ||
+---client | ||
| | app.js | ||
| | chain-smart-bsc-l.png | ||
| | index.css | ||
| | index.html | ||
| | | ||
| | ||
+---contracts | ||
| HelloWorld.sol | ||
| Migrations.sol | ||
| | ||
+---migrations | ||
| 1_initial_migration.js | ||
| 2_hello_world.js | ||
| | ||
+---server | ||
| main.js | ||
| | ||
+---test | ||
| .gitkeep | ||
| hello_world.js | ||
| | ||
``` | ||
|
||
## How it Works | ||
### Checklist | ||
- Make sure you have MetaMask installed and logged in on your browser. | ||
- Make sure that your MetaMask wallet is correctly configured to connect to BSC Testnet. Refer to this [guide](https://academy.binance.com/en/articles/connecting-metamask-to-binance-smart-chain) for details. | ||
- Create a file named ```.secret```, save your MetaMask Secret Phrase in this file. | ||
- Run the command ```truffle compile``` to compile the smart contracts. | ||
- Run the command ```truffle migrate --reset --network bscTestnet``` to deploy the contract on the BSC Testnet. | ||
- Run the command ```npm run build``` to build the application. | ||
- Run the command ```npm run dev``` to start the application. | ||
|
||
### How to Use | ||
1. Open browser and navigate to ```http://localhost:3000/``` | ||
2. Make sure that your MetaMask wallet is correctly installed and configured to connect to BSC Testnet. Refer to this [guide](https://academy.binance.com/en/articles/connecting-metamask-to-binance-smart-chain) for details. | ||
3. Select your desired account of MetaMask that has BNB Test tokens to perform transactions. | ||
4. To get test tokens use the [BNB Smart Chain Faucet](https://testnet.binance.org/faucet-smart). | ||
5. Click on Greet Button to display message, by default its Hello World. | ||
6. Enter a name in the input field, Click save button to save the name. | ||
7. Confirm the transaction when MetaMask notification pops up. | ||
8. Click on Greet Button to display message along with the last name saved with the current account. | ||
|
||
## Unit Test of Smart Contracts | ||
- Make sure that Ganache is running. This is important because testing is done on the local network. | ||
- From the root directory of the project, open command prompt. | ||
- Run the command ```truffle test``` to run the tests. | ||
|
||
## Unit Test Coverage | ||
```sh | ||
Contract: HelloWorld | ||
√ Default message should be hello, world (264ms) | ||
√ Should save name (796ms) | ||
√ Should be default message for other accounts (412ms) | ||
√ Should throw error on empty name (3306ms) | ||
|
||
|
||
4 passing (5s) | ||
``` | ||
## Contact | ||
For more inquiries and conversations, feel free to contact me at [email protected] | [email protected] |
11,552 changes: 11,552 additions & 0 deletions
11,552
01- Hello World Full Stack dApp on BSC/build/contracts/HelloWorld.json
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.