|
| 1 | +## VMBC Ethers Sample DApps |
| 2 | + |
| 3 | +### Table of Contents |
| 4 | +1. [Overview](#overview) |
| 5 | +2. [Prerequisites](#prerequisites) |
| 6 | +3. [Deploying Contract using Hardhat](#deploying-contract-using-hardhat) |
| 7 | +4. [Sample 1 - Get Greeting](#sample-1---get-greeting) |
| 8 | +5. [Sample 2 - Set Greeting](#sample-2---set-greeting) |
| 9 | +6. [Sample 3 - Data Copy](#sample-3---data-copy) |
| 10 | +7. [Sample 4 - Batching](#sample-4---batching) |
| 11 | + |
| 12 | +### Overview |
| 13 | +Samples for using VMBC Ethers |
| 14 | + |
| 15 | +### Prerequisites |
| 16 | +* Deploy VMware Blockchain |
| 17 | +* Install npm packages |
| 18 | +```sh |
| 19 | +# For hardhat related config |
| 20 | +npm install |
| 21 | +cd sample-dapps |
| 22 | +# For sample dapps |
| 23 | +npm install |
| 24 | +``` |
| 25 | + |
| 26 | +### Deploying Contract using Hardhat |
| 27 | +Following command uses `vmbc` network from inside the file `hardhat.config.js` |
| 28 | +```sh |
| 29 | +npx hardhat run --network vmbc scripts/deploy.js |
| 30 | +``` |
| 31 | +Note: Make a note of Contract Address of Greetings Smart Contract from the output of above command |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +### Sample 1 - Get Greeting |
| 36 | +#### Overview |
| 37 | +* This sample depicts way to use view functions of deployed smart contracts |
| 38 | +#### Setup |
| 39 | +* Update the `CONTRACT_ADDRESS` to the contract address received from Deploying usin Hardhat step |
| 40 | +#### Executing |
| 41 | +```sh |
| 42 | +node 1_get_greetings.js |
| 43 | +``` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +### Sample 2 - Set Greeting |
| 48 | +#### Overview |
| 49 | +* This sample depicts way to call any write based functions of deployed smart contracts |
| 50 | +#### Setup |
| 51 | +* Update the `CONTRACT_ADDRESS` to the contract address received from Deploying usin Hardhat step |
| 52 | +* Update the `PRIVATE_KEY_ACC` to the private key of an account |
| 53 | +#### Executing |
| 54 | +```sh |
| 55 | +node 2_set_greetings.js |
| 56 | +``` |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +### Sample 3 - Data Copy |
| 61 | +#### Overview |
| 62 | +* This sample depicts following aspects, |
| 63 | + * Compiling a Smart Contracts in JavaScript using `solc` |
| 64 | + * Deploying the Smart Contract |
| 65 | + * Interacting with programatically deployed Smart Contracts |
| 66 | +#### Setup |
| 67 | +* Update the `PRIVATE_KEY_ACC` to the private key of an account |
| 68 | +#### Executing |
| 69 | +```sh |
| 70 | +node 3_data_copy.js |
| 71 | +``` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +### Sample 4 - Batching |
| 76 | +#### Overview |
| 77 | +* This sample depicts following aspects, |
| 78 | + * Batching of multiple read based calls |
| 79 | + * Batching of multiple write based transactions |
| 80 | +#### Setup |
| 81 | +* Update `ACCOUNT_1`, `ACCOUNT_2`, `ACCOUNT_3` and `ACCOUNT_4` to the account addresses for 4 accounts |
| 82 | +* Update the corresponding `PRIVATE_KEY_ACC_1` and `PRIVATE_KEY_ACC_3` to the private key of those two accounts |
| 83 | +#### Executing |
| 84 | +```sh |
| 85 | +node 4_batching.js |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
0 commit comments