Skip to content

Commit 88a3874

Browse files
authored
Merge pull request #481 from ProvableHQ/rr-update-local-deployment-guide
Update local deployment guide
2 parents a78bb07 + 0e6eda0 commit 88a3874

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

documentation/testing/03_devnet.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ A local devnet can be a heavyweight but reliable way to test your application on
88

99
## Setup
1010

11-
To run a local devnet, you'll need to install [snarkOS](https://developer.aleo.org/guides/introduction/getting_started#2-installing-snarkos).
11+
To run a local devnet, you'll need to install [snarkOS](https://developer.aleo.org/guides/introduction/getting_started#2-installing-snarkos).
12+
Be sure to use the latest [release](https://github.com/ProvableHQ/snarkOS/releases).
1213
You'll also need `tmux` (instructions below) and the [devnet.sh](https://github.com/ProvableHQ/snarkOS/blob/staging/devnet.sh) script in the `snarkOS` repository.
1314

1415
<details><summary>macOS</summary>
@@ -49,7 +50,20 @@ sudo apt install tmux
4950

5051
### Runing the Devnet
5152

52-
Run the `devnet.sh` script and follow the prompts.
53+
From the root of the SnarkOS repository, run the `devnet.sh` script and follow the prompts. Alternatively, you can copy the script to your project's directory.
54+
55+
```bash
56+
Enter the total number of validators (default: 4):
57+
Enter the total number of clients (default: 2):
58+
Enter the network ID (mainnet = 0, testnet = 1, canary = 2) (default: 1):
59+
Do you want to run 'cargo install --locked --path .' to build the binary? (y/n, default: y): n
60+
Do you want to clear the existing ledger history? (y/n, default: n):
61+
```
62+
Note: The minimum number of validators to run a local devnet is 4.
63+
64+
If you have already installed the SnarkOS CLI, you do not need to build the binary.
65+
66+
Clearing the ledger history may be useful if you wish to redploy your program without changing the name. However, this will erase all transaction history and start a new instance of the Aleo blockchain from genesis.
5367

5468
`tmux` allows you to toggle between nodes in your local devnet. Here are some useful (default) commands:
5569

@@ -67,3 +81,66 @@ Ctrl+b :select-window -t {NODE_ID}
6781
# To stop a local devnet
6882
Ctrl+b :kill-session
6983
```
84+
85+
### Interacting with your program
86+
87+
## Deploy
88+
89+
When deploying programs to a local devnet, make sure that your `.env` file matches the one below:
90+
91+
```bash
92+
NETWORK=testnet
93+
PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH
94+
ENDPOINT=http://localhost:3030
95+
```
96+
97+
The PRIVATE_KEY above is same one that is generated by default when you create a new Leo project using the `leo new` command. It will be seeded with ample test credits in the devnet.
98+
To deploy your program, run the following command:
99+
```bash
100+
leo deploy
101+
```
102+
103+
## Executing Transactions
104+
105+
After deploying your program, you can call methods using the following command syntax:
106+
```bash
107+
leo execute <method_name> [input1] [input2...] --program <program_name>.aleo --broadcast
108+
```
109+
110+
## API endpoints
111+
112+
You can check your transactions by using the following API endpoint:
113+
114+
```bash
115+
GET http://localhost:3030/testnet/transaction/{transaction_id}
116+
```
117+
118+
The transaction API endpoint is instructive in verifying whether a transaction succeeded or failed. Since both successful and failed transaction execute a fee transaction, if only the fee transaction appears, that is a clear indication that the transaction has failed. Note that on the Testnet and on Mainnet, failed transactions still require a fee since the network is performing a computation.
119+
120+
A full list of API endpoints is available [here](https://developer.aleo.org/references/apis/public_api/)
121+
122+
## Record Scanning
123+
124+
You can use the SnarkOS CLI to view your Records using the following command syntax:
125+
```bash
126+
snarkos developer scan --endpoint http://localhost:3030 --private-key APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH --start <block_number> --network 1
127+
```
128+
129+
Setting `block_number` to `0` will list all of the records from genesis, including your test credit records.
130+
131+
```bash
132+
⚠️ Attention - Scanning the entire chain. This may take a while...
133+
134+
Scanning 3 blocks for records (100% complete)...
135+
136+
[
137+
"{ owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, microcredits: 23437500000000u64.private, _nonce: 3666670146276262240199958044811329632452609778779651964870759629195088099828group.public}",
138+
"{ owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, microcredits: 23437500000000u64.private, _nonce: 4536868268814456227312360347031739423312689137706933033938812386306238998060group.public}",
139+
"{ owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, microcredits: 23437500000000u64.private, _nonce: 205967862164714901379497326815256981526025583494109091059194305832749867953group.public}",
140+
"{ owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, microcredits: 23437500000000u64.private, _nonce: 4424806931746512507605174575961455750579179367541686805196254590136284583805group.public}"
141+
]
142+
```
143+
144+
Setting `block_number` to `1` or higher will exclude the above credit records from the scan.
145+
146+

0 commit comments

Comments
 (0)