-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add gnolang/faucet
#2122
docs: add gnolang/faucet
#2122
Changes from 13 commits
fc80b83
0026cda
449403a
a4584ec
d38ac5f
13795e3
040f5f2
5cc17a9
e8b32c4
f7619a4
fd6fb8a
47b1a5c
6cb0ea4
fbb91ed
3586699
30c14d2
e6e4883
15028c7
6aeb1f5
e33f6e3
d2388e7
712653f
6537dca
451c0a9
2e497c8
c4904a8
c8ec215
c70112c
33fff40
6ba72bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
id: gno-infra | ||
--- | ||
|
||
# Gno Infra | ||
|
||
Welcome to the **Gno Infra** section for Gno. This section is meant for users | ||
wanting to learn how to run their own Gno node, set up their own faucet, run | ||
an indexer service, and more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
--- | ||
id: setting-up-a-faucet | ||
--- | ||
|
||
# Setting up a faucet for your Gno network | ||
|
||
In this tutorial, we will cover how to run a local native currency faucet that | ||
works seamlessly with a Gno node. Using the faucet, any address can get a hold | ||
of testnet GNOTs. | ||
|
||
## Prerequisites | ||
- Git | ||
- Go 1.21+ | ||
- Make (for running Makefiles) | ||
- `gnoland` & `gnokey` installed | ||
- A Gno.land keypair generated using [`gnokey`](../gno-tooling/cli/gnokey.md) | ||
|
||
## Premining funds to an address | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should drop this section completely, and not reference There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed this section and added a prerequisite: 6aeb1f5 |
||
|
||
Before setting up the faucet, we need to make sure that the address will be used | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a correct English sentence:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section was completely removed as per #2122 (comment) |
||
to serve the funds contain enough testnet funds. | ||
|
||
In your monorepo clone, visit the `genesis_balances.txt` file in the | ||
`gno.land/genesis` folder. This file contains a list of addresses and their | ||
initial balances upon chain initialization. The file follows the pattern below | ||
for premining specific amounts of GNOT to an address. | ||
|
||
``` | ||
g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5=10000000000000ugnot # test1 | ||
g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj=10000000000000ugnot # test2 | ||
``` | ||
|
||
Add the address you plan to use for your faucet in the same format: | ||
|
||
``` | ||
<address>=<amount>ugnot | ||
``` | ||
|
||
After this, you can spin up your chain and run the following command to check | ||
that the address indeed contains the intended balances: | ||
|
||
```bash | ||
gnokey query bank/balances/<address> --remote <node_rpc_listener_address> | ||
``` | ||
|
||
Running this command will output something like the following: | ||
|
||
```bash | ||
height: 0 | ||
data: "10000000000000ugnot" | ||
``` | ||
|
||
Now this address is ready to be used for the faucet. | ||
|
||
## Cloning the repo | ||
|
||
To get started with setting up the faucet, visit the | ||
[faucet repo](https://github.com/gnolang/faucet) and clone it: | ||
|
||
```bash | ||
git clone [email protected]:gnolang/faucet.git | ||
``` | ||
|
||
After going into the cloned folder, you can build out the faucet binary: | ||
```bash | ||
make build | ||
``` | ||
|
||
We are now ready to configure & run the faucet. | ||
|
||
## Configuring the faucet | ||
|
||
By running the `generate` command from the faucet binary, you will be able to generate | ||
a `config.toml` file. | ||
|
||
```bash | ||
./build/faucet generate | ||
``` | ||
|
||
In the `config.toml` file, you will be able to configure a few parameters: | ||
- ChainID of the node to connect to | ||
- Faucet listener address | ||
- Mnemonic phrase to use for generating the account(s) to serve funds from | ||
- The number of accounts to generate from the mnemonic | ||
- The maximum drip amount for the faucet | ||
- CORS configuration of the faucet | ||
|
||
The default config file looks like this: | ||
```yaml | ||
chain_id = "dev" | ||
listen_address = "0.0.0.0:8545" | ||
mnemonic = "<your_mnemonic_phrase>" | ||
num_accounts = 1 | ||
send_amount = "1000000ugnot" | ||
|
||
[cors_config] | ||
cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"] | ||
cors_allowed_methods = ["HEAD", "GET", "POST", "OPTIONS"] | ||
cors_allowed_origins = ["*"] | ||
``` | ||
|
||
After inputting the mnemonic phrase from which your faucet address is derived | ||
from, you are ready to run the faucet. | ||
|
||
## Running the faucet | ||
|
||
To run the faucet, simply run the following command: | ||
|
||
```bash | ||
> ./build/faucet serve --faucet-config <path_to_config.toml> | ||
|
||
time=2024-05-16T11:25:36.012+02:00 level=INFO msg="faucet started at [::]:8545" | ||
``` | ||
|
||
The faucet should be running on `localhost:8545`, and is connected to the locally | ||
running `gnoland` instance. By default, `gnoland`'s rpc listener address is matched | ||
in the `--remote` flag in the faucet. If your node is listening on a separate | ||
address, make sure to match it accordingly when running the faucet. | ||
|
||
## Making faucet requests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error handling was not covered in this section, please cover it 🙏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added possible errors a user can have while setting up the faucet or when making requests: |
||
|
||
The faucet takes in standard HTTP post requests with JSON data. The basic request | ||
format is the following: | ||
|
||
```json | ||
{ | ||
"To": "g1juz2yxmdsa6audkp6ep9vfv80c8p5u76e03vvh" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is outdated, please reference the latest There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A request without an |
||
} | ||
``` | ||
|
||
You can test this out buy running the following `curl` command: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo here, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch, fixed it: 15028c7 |
||
```bash | ||
curl --location --request POST 'http://localhost:8545' --header 'Content-Type: application/json' --data '{"To": "g1juz2yxmdsa6audkp6ep9vfv80c8p5u76e03vvh"}' | ||
``` | ||
|
||
If the request is successful, you should get an output similar to the following: | ||
```bash | ||
{"result":"successfully executed faucet transfer"} | ||
``` | ||
|
||
The faucet also supports batch requests, so a request such as the following is | ||
also valid: | ||
|
||
```json | ||
[ | ||
{ | ||
"To": "g1juz2yxmdsa6audkp6ep9vfv80c8p5u76e03vvh" | ||
}, | ||
{ | ||
"To": "g1zzqd6phlfx0a809vhmykg5c6m44ap9756s7cjj" | ||
} | ||
] | ||
``` | ||
|
||
Sending this to the faucet will receive the following response: | ||
|
||
```json | ||
[ | ||
{ | ||
"result": "successfully executed faucet transfer" | ||
}, | ||
{ | ||
"result": "successfully executed faucet transfer" | ||
} | ||
] | ||
``` | ||
|
||
## Conclusion | ||
|
||
That's it 🎉 | ||
|
||
You have successfully set up a GNOT faucet on for a local Gno.land chain! | ||
Read more about the faucet on the [`faucet`](https://github.com/gnolang/faucet) repo. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
id: gno-tooling-tm2-faucet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the use of this file is, it can become outdated very quickly (help output) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed it: fbb91ed |
||
--- | ||
|
||
# TM2 Faucet | ||
|
||
TM2 Faucet is a versatile command-line interface (CLI) tool designed to | ||
effortlessly deploy a faucet server for Gno Tendermint 2 networks. The tool can | ||
be found on the [`gnolang/faucet`](https://github.com/gnolang/faucet) repo. | ||
|
||
## Run `faucet` Commands | ||
|
||
### `generate` | ||
|
||
Generates a `config.toml` file for the faucet. | ||
|
||
-output-path ./config.toml the path to output the TOML configuration file | ||
|
||
#### **Options** | ||
|
||
| Name | Type | Description | | ||
|---------------|---------|------------------------------------------------| | ||
| `output-path` | String | The path to output the TOML configuration file | | ||
|
||
### `serve` | ||
|
||
Starts the faucet with the default or given config. | ||
|
||
```bash | ||
faucet serve | ||
``` | ||
|
||
#### **Options** | ||
|
||
| Name | Type | Description | | ||
|------------------|--------|------------------------------------------------------------------| | ||
| `chain-id` | String | The id of the chain (required). | | ||
| `config` | String | the path to the command configuration file [TOML] | | ||
| `faucet-config` | String | the path to the faucet TOML configuration, if any | | ||
| `gas-fee` | String | he static gas fee for the transaction. Format: <AMOUNT>ugnot | | ||
| `gas-wanted` | String | the static gas wanted for the transaction. Format: <AMOUNT>ugnot | | ||
| `listen-address` | String | the IP:PORT URL for the faucet server | | ||
| `mnemonic` | String | the mnemonic for faucet keys | | ||
| `num-accounts` | String | the number of faucet accounts, based on the mnemonic | | ||
| `remote` | String | the JSON-RPC URL of the Gno chain | | ||
| `send-amount` | String | the static max send amount per drip (native currency) | |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tutorial doesn't cover:
gnofaucet
gnofaucet
vsgnolang/faucet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the original issue, this tutorial was meant to cover setting up a faucet with
gnolang/faucet
, which it does.I suggest two options:
gnolang/faucet
, and open a separate issue for documentinggnofaucet
. Ideally, we would have some reference docs or at least a basic README about it before I start working on it.gnofaucet
functionalities and codebase - understanding the details of it are a requirement for me to be able to write a high-quality tutorial. Possibly we can jump on a quick 15 min call and you can run me through the main functionalities to speed up the process, and get this done asap?I have fixed up all of the other comments as requested, and added a section mentioning that the faucet can be extended and referenced
gnofaucet
as an example: d2388e7WDYT?
cc @Kouteki
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like option 1 better - it lets us publish this PR and make incremental progress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leohhhn
We discussed on a call that
gnofaucet
is most definitely in the scope of this PR, and should be added -- please add it and ping me when it's up in the PR 🙏There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly speaking, I do not remember discussing this on a call.
However, I did take about 2h to read through the code of
gnofaucet
and write up a section on it. Please check it out.I've also added a mention of the Faucet Hub.