Skip to content

prosopo/polkadot-testnet-faucet

 
 

Repository files navigation

Generic Faucet for Substrate based chains

GitHub Issue Sync

Development

Setup dependencies and git hooks

yarn install
yarn simple-git-hooks

start local database:

yarn dev:db

run migrations:

yarn migrations:run

creating migrations:

  • update entities in src/db/entity
  • run yarn migrations:generate src/db/migration/<migration_name>
  • import generated migration to src/db/dataSource.ts

To launch a hot-reloading dev environment

yarn dev

Environment variables

Definition with explanation is in ./env.faucet.config.json

Copy example file to real env and change its values:

$ cp example.env .env

End-to-end tests

Please refer to the E2E Readme.

Example requests:

curl -X POST \
  localhost:5555/drip/web \
  -H "Content-Type: application/json" \
  -d '{"address": "xxx", "parachain_id": "1002", "captchaResponse": "captcha_token"}'

In React:

import ReCAPTCHA from "react-google-recaptcha";

(...)

const [captcha, setCaptcha] = useState<string | null>(null)

(...)

<ReCAPTCHA
  sitekey="xxx"
  onChange={setCaptcha}
/>

(...)

const request = async () => {
  const body = {
    address: "xxx",
    parachain_id: "1002",
    captchaResponse: captcha_token
  }

  const fetchResult = await fetch("http://localhost:5555/drip/web", {
    method: "POST", body: JSON.stringify(body), headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
  })
  const result = await fetchResult.json()
}

Where the captcha_token is either a

  • JSON payload that includes a verified rococo address procaptcha

or

  • a recaptcha token created with a sitekey matching the recaptcha secret specified in SMF_BACKEND_RECAPTCHA_SECRET.

For testing, you can use

  • Alice's address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY with procaptcha

or

  • a public, testing captcha secret which will allow any captcha token to pass with recaptcha.

    # Public testing secret, will accept all tokens.
    SMF_BACKEND_RECAPTCHA_SECRET="6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"

Helm chart

An official substrate-faucet helm chart is available for deploying the faucet.

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 /metrics
  • Readiness check URL via ready
  • Health check URL via /health

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 79.8%
  • Svelte 15.0%
  • JavaScript 2.0%
  • CSS 1.6%
  • Dockerfile 1.0%
  • HTML 0.5%
  • Shell 0.1%