Skip to content

patractlabs/substrate-matrix-faucet

 
 

Repository files navigation

Generic Faucet for Substrate based chains

Development

Setup dependencies and git hooks

yarn install
yarn simple-git-hooks

To launch a hot-reloading dev environment

yarn dev:backend
yarn dev:bot

Server environment variables

The only common variable between the bot and the server is the NETWORK_DECIMALS. Also the server's PORT should be part of the bot's BACKEND_URL.

Setup a .env file with the following variables

FAUCET_ACCOUNT_MNEMONIC #required - mnemonic seed from faucet account
FAUCET_BALANCE_CAP # optional - Upper limit cap on whether or not the account can recieve more tokens. Defaults to 100.
INJECTED_TYPES #optional - if any type must be overriden
NETWORK_DECIMALS #optional - decimal amount for the network
PORT #optional - the port you want the server to listen on
RPC_ENDPOINT #required - ws rpc node endpoint

example:

FAUCET_ACCOUNT_MNEMONIC="this is a fake mnemonic"
FAUCET_BALANCE_CAP=100
INJECTED_TYPES="{ "Address": "AccountId", "LookupSource": "AccountId" }"
NETWORK_DECIMALS=12
PORT=5555
RPC_ENDPOINT="https://westend-rpc.parity.io/"

Bot environment variables

Setup a .env file with the following variables

BACKEND_URL #optional - full url for the bot to reach the backend
DRIP_AMOUNT #optional - default amount of token to send
MATRIX_ACCESS_TOKEN #required - your bot access token here is how to find it https://t2bot.io/docs/access_tokens/
MATRIX_BOT_USER_ID #required - your bot user id
NETWORK_DECIMALS #optional - decimal amount for the network
NETWORK_UNIT #optional - token unit for the network

example:

BACKEND_URL="http://localhost:5555"
DRIP_AMOUNT=10
MATRIX_ACCESS_TOKEN="ThisIsNotARealAccessToken"
MATRIX_BOT_USER_ID="@test_bot_faucet:matrix.org"
NETWORK_DECIMALS=12
NETWORK_UNIT="CAN"

Ignore List / Blacklist

A list of Matrix accounts that will be silently (but logged) ignored:

FAUCET_IGNORE_LIST="@alice:matrix.org,@bob:domain.com"

Helm deployment / Adding a new faucet

  1. Create an account for your MATRIX_BOT_USER_ID at https://matrix.org/, login and retrieve MATRIX_ACCESS_TOKEN in Settigns -> Help and about -> click to reveal

  2. Create a chainName-values.yaml file and define all non default variables. Secret variables (MATRIX_ACCESS_TOKEN & FAUCET_ACCOUNT_MNEMONIC) you need to supply externally via CI / command line / ...

  3. Create a new CI-Job / Environment in .gitlab-ci.yml file and add Secrets (in clear / non-base64 encoded format) to gitlab -> CI/CD Settings -> Secret Variables).

  4. Run CI/CD or use helm to deploy.

Example Helm usage:

helm template westend . \
 --values ./westend-values.yaml \
 --set server.secret.FAUCET_ACCOUNT_MNEMONIC='ich und du muellers esel das bist du' \
 --set server.image.dockerTag=latest \
 --set bot.secret.MATRIX_ACCESS_TOKEN='asdf-not-a-secret-asfd'

helm -n faucetbots ls --all

helm -n faucetbots rollback westend 2

Misc:

  • Bump API: yarn upgrade @polkadot/util@latest @polkadot/wasm-crypto@latest @polkadot/keyring@latest @polkadot/x-randomvalues@latest @polkadot/api@latest @polkadot/keyring@latest @polkadot/util-crypto@latest
  • Server can be queried for Prometheus metrics via http://$BACKEND_URL/metrics
  • Readiness check URL via http://$BACKEND_URL/ready
  • Health check URL via http://$BACKEND_URL/health

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.3%
  • Mustache 6.7%