You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: basics/ethereum/vrf/README.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -194,3 +194,57 @@ forge install
194
194
# Run tests
195
195
forge test
196
196
```
197
+
198
+
## 6. Hands-on Practice
199
+
200
+
The Lottery contract is deployed and verified on BSC Testnet at [0x27e5De33cB6d31894a875891D3D86aA5F5b8aB2a](https://testnet.bscscan.com/address/0x27e5De33cB6d31894a875891D3D86aA5F5b8aB2a#readContract).
201
+
202
+
### 6.1 Interacting with the Contract
203
+
204
+
There are two ways to interact with the deployed contract:
205
+
206
+
1.**Using Script**
207
+
- Use the provided `JoinLottery.s.sol` script
208
+
- Set required environment variables (refer to `.env.example`):
- Connect your wallet (e.g., MetaMask) to BSC Testnet
223
+
- Visit the contract page on BSCScan
224
+
- Use the "Write Contract" section to interact with the contract
225
+
- Make sure your wallet has enough BNB for gas fees (at least 0.008 BNB for VRF fee)
226
+
227
+
### 6.2 Getting Test BNB
228
+
229
+
To get test BNB for the BSC Testnet:
230
+
1. Join the [BSC Discord](https://discord.com/invite/bnbchain)
231
+
2. Follow the guide in the #faucet-guide channel
232
+
3. Request test BNB from the faucet
233
+
234
+
### 6.3 Transaction Flow
235
+
236
+
When you interact with the contract, you can observe the following transaction flow:
237
+
238
+
1. **Join Transaction**
239
+
- When you call the `join` function, a transaction is sent to the BSC Testnet
240
+
- This transaction includes the VRF request fee and initiates the random number generation process
241
+
- Example transaction: [0x94a9e62a5a35af01a671b14a3bb9092d97abaa22494989dbc2c4faa27a3ec5ad](https://testnet.bscscan.com/tx/0x94a9e62a5a35af01a671b14a3bb9092d97abaa22494989dbc2c4faa27a3ec5ad)
242
+
243
+
244
+
2. **VRF Callback Transaction**
245
+
- After approximately 3 blocks, Chainlink VRF generates the random number
246
+
- The `fulfillRandomWords`functionis automatically called with the random number
247
+
- This determines if you win and handles prize distribution
248
+
- Example transaction: [0xba1612cc888d270ab380cc2776e5a4156e26fa7c371872f2a3d288d001800d90](https://testnet.bscscan.com/tx/0xba1612cc888d270ab380cc2776e5a4156e26fa7c371872f2a3d288d001800d90)
249
+
250
+
The entire process demonstrates how Chainlink VRF provides provably fair random numbers in a decentralized manner, with each step verifiable on the blockchain.
0 commit comments