Skip to content
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

Faucet API #1

Merged
merged 10 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
.env
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts:
builds
lib
node_modules
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
## Service Description

This simple API allows users to be funded with native token of the connected network.
The secret of an account with funds is passed as environment variable. When a user request funds,
The secret of an account with funds is passed as environment variable. When a user requests funds,
a transaction from the balances pallet is made to the user's address.

In order to use the faucet, make a GET request to `/fund?to={your-public-address}`, which will trigger
the transaction and respond to the user if the funding was successful.

## Rate limiting

An address can only be funded X times every 60 minutes, where it must also wait for Y minutes between
each funding. Both values can be configured in `config.json` by setting `limitPerHour` and `minWaitTimeMinutes`
respectively.
Alternatively, the requests per IP can be configured by `RATE_LIMIT_MAX_REQUESTS` and `RATE_LIMIT_WINDOW_MINUTES`.

## Error handling

If an error arises during the transfer (like a lack of funds from the sender account), a message
If an error arises during the transfer (like a lack of funds from the sender's account), a message
will be sent to the corresponding slack channel specified via environment.
To avoid sending multiple messages, only one type of error will be sent every period of time,
here defined as 8 hours.
Expand All @@ -16,7 +26,7 @@ here defined as 8 hours.
### Mandatory

- `SLACK_WEB_HOOK_TOKEN` - Slack web hook token for error reporting.
- `SUBSTRATE_SECRET_PHRASE` - Substrate account secret used by the service to fund user's accounts.
- `SUBSTRATE_SECRET_PHRASE` - Substrate account secret used by the service to fund user's account.

### Optional

Expand Down
11 changes: 11 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"network": {
"name": "foucoco",
"wss": "wss://rpc-foucoco.pendulumchain.tech",
"addressPrefix": 57,
"decimals": 12,
"fundAmount": 100,
"limitPerHour": 2,
"minWaitTimeMinutes": 1
}
}
Loading