Skip to content

Commit 0eb5b7c

Browse files
Quick start/dice game tutorial (#335)
* added index file for dice game contract * Added contract code and deployment steps * inter-contract calls description added * added references/message proto file code * hygiene fixes * hygiene fixes-2 * quick-start/dice-game-tutorial --------- Co-authored-by: RutvikGhaskataEalf <[email protected]>
1 parent 31992e9 commit 0eb5b7c

17 files changed

+3323
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#### Create A Wallet
2+
3+
To send transactions on the aelf blockchain, you must have a wallet.
4+
5+
- Run this command to create aelf wallet.
6+
7+
```bash title="Terminal"
8+
aelf-command create
9+
```
10+
11+
![result](/img/create_wallet_output.png)
12+
13+
- You will be prompted to save your account, please do **save** your account as shown below:
14+
15+
```bash title="Terminal"
16+
? Save account info into a file? (Y/n) Y
17+
```
18+
19+
**Make sure to choose Y to save your account information.**
20+
21+
:::tip
22+
ℹ️ Note: If you do not save your account information (by selecting n or N), do not export the wallet password. Only **proceed to the next** step if you have saved your account information.
23+
:::
24+
25+
- Next, enter and confirm your password. Then export your wallet password as shown below:
26+
27+
<Tabs>
28+
<TabItem value="Linux and macOs" label="Linux and macOs" default>
29+
```bash title="Terminal"
30+
export WALLET_PASSWORD="YOUR_WALLET_PASSWORD"
31+
```
32+
</TabItem>
33+
34+
<TabItem value="Windows" label="Windows">
35+
```bash title="Command Prompt"
36+
$env:WALLET_PASSWORD = "YOUR_WALLET_PASSWORD"
37+
```
38+
</TabItem>
39+
</Tabs>
40+
41+
#### Acquire Testnet Tokens (Faucet) for Development
42+
43+
To deploy smart contracts or execute on-chain transactions on aelf, you'll require testnet ELF tokens.
44+
45+
**Get ELF Tokens**
46+
47+
Go to https://faucet-ui.aelf.dev Enter your address and click `Get Tokens`.
48+
49+
![result](/img/get-token-ui.png)
50+
51+
**Deploy Smart Contract:**
52+
53+
The smart contract needs to be deployed on the chain before users can interact with it.
54+
55+
Run the following command to deploy a contract. Remember to export the path of DiceMaster.dll.patched to CONTRACT_PATH.
56+
57+
<Tabs>
58+
<TabItem value="Linux and macOs" label="Linux and macOs" default>
59+
```bash title="Terminal"
60+
export CONTRACT_PATH=$(find ~+ . -path "*patched*" | head -n 1)
61+
```
62+
63+
```bash title="Terminal"
64+
aelf-deploy -a $WALLET_ADDRESS -p $WALLET_PASSWORD -c $CONTRACT_PATH -e https://tdvw-test-node.aelf.io/
65+
```
66+
67+
</TabItem>
68+
69+
<TabItem value="Windows" label="Windows">
70+
```bash title="Command Prompt"
71+
$CONTRACT_PATH = Get-ChildItem -Recurse -Filter "*patched*" | Select-Object -First 1 -ExpandProperty FullName
72+
$env:CONTRACT_PATH = $CONTRACT_PATH
73+
```
74+
75+
```bash title="Command Prompt"
76+
aelf-deploy -a $env:WALLET_ADDRESS -p $env:WALLET_PASSWORD -c $env:CONTRACT_PATH -e https://tdvw-test-node.aelf.io/
77+
```
78+
79+
</TabItem>
80+
</Tabs>
81+
82+
- Please wait for approximately 1 to 2 minutes. If the deployment is successful, it will provide you with the contract address.
83+
![result](/img/deploy-result.png)
84+
85+
- Copy the smart contract address from the `address` field
86+
![result](/img/Contract_Address.png)
87+
88+
- Export your smart contract address:
89+
90+
<Tabs>
91+
<TabItem value="Linux and macOs" label="Linux and macOs" default>
92+
```bash title="Terminal"
93+
export CONTRACT_ADDRESS="YOUR_SMART_CONTRACT_ADDRESS e.g. 2LUmicHyH4RXrMjG4beDwuDsiWJESyLkgkwPdGTR8kahRzq5XS"
94+
```
95+
</TabItem>
96+
97+
<TabItem value="Windows" label="Windows">
98+
```bash title="Command Prompt"
99+
$env:CONTRACT_ADDRESS="YOUR_SMART_CONTRACT_ADDRESS e.g. 2LUmicHyH4RXrMjG4beDwuDsiWJESyLkgkwPdGTR8kahRzq5XS"
100+
```
101+
</TabItem>
102+
</Tabs>
103+
104+
:::tip
105+
ℹ️ Note: You are to copy the smart contract address as we will be referencing it in the next steps!
106+
:::
107+
108+
:::info
109+
🎉 You have successfully deployed your dApp smart contract on the aelf testnet! In the next steps, we will be building the frontend components that allow us to interact with our deployed smart contract!
110+
:::
111+
112+

0 commit comments

Comments
 (0)