Giter VIP home page Giter VIP logo

tezos-faucet's Introduction

Tezos Faucet Frontend

Presentation

A one-click faucet for Tezos, now enhanced with a PoW (Proof of Work) challenge to ensure secure and fair Tez distribution.

Made with

  • Typescript
  • Vite
  • React
  • Bootstrap
  • Taquito
  • Beacon Wallet

Overview

The faucet's backend code can be located at tezos-faucet-backend. The backend handles the faucet's private key, CAPTCHA secret, PoW challenge creation and solution verification, and the amounts of Tez sent.

Proof of Work (PoW) Challenge

To mitigate potential abuse and ensure a fair distribution of Tez, users are now required to solve computational challenges before receiving their Tez. This PoW mechanism discourages bots and other malicious actors from exploiting the faucet.

Application Flow

  1. Initiating the Process: Upon a Tez request, the frontend communicates with the /challenge endpoint of the backend, providing essential details such as the user's address and the amount of Tez requested.
  2. Receiving and Solving the Challenge: The backend then sends a challenge. The difficulty and amount of challenges to be solved depends on factors such as if a CAPTCHA token was submitted and how much Tez was requested. The browser will create a webworker which will begin the process of finding a solution.
  3. Submitting and Verifying the Solution: After solving, the frontend sends the solution to the /verify endpoint. The backend then checks its validity. Assuming it is valid, if more challenges are pending, the user proceeds to solve them. Once all challenges are cleared, Tez is sent to the user's account.

Programmatic Faucet Usage

For programmatic usage of the faucet, we provide an npm package @oxheadalpha/get-tez. The code can be found here. Please refer to it for more details on how to use it. This script can be run from a JavaScript program or directly from a shell. It interacts with the backend to request Tez, solve the required challenges, and verify the solutions.

Please note that the programmatic faucet code does not use CAPTCHA and so more challenges can be given when using it.

Setup

To setup the faucet for a new network:

  1. Update Beacon Wallet lib to make sure it will handle the new network
  2. Deploy a new instance of backend
  3. Configure faucet to use backend
  4. Deploy faucet

1. Update Beacon Wallet configuration for new network

Currently supported networks include:

  • Mainnet
  • Ghostnet
  • Mondaynet
  • Dailynet
  • Nairobinet
  • Oxfordnet

To add a new network, first check that @airgap/beacon-sdk handles it (check their config on the latest release), then update:

npm i @airgap/beacon-sdk

2. Deploy backend

See https://github.com/oxheadalpha/tezos-faucet-backend

3. Update configuration file: config.json

Application configuration:

  • name: application name, displayed in header

  • googleCaptchaSiteKey: Google ReCAPTCHA public site key

  • backendUrl: Base URL of faucet backend to connect to.

  • githubRepo: URL of Github repository (displayed in header with Github icon).

  • disableChallenges: If PoW challenges need to be solved before receiving Tez. The backend must also disable challenges. Defaults to false.

  • minTez: The minimum amount of Tez that can be requested.

  • maxTez: The maximum amount of Tez that can be requested.

Network configuration:

  • name: network name. Must match one of @airgap/beacon-sdk NetworkType value (case insensitive). Also used to be displayed.

  • rpcUrl: Tezos network RPC endpoint to be used by faucet

  • faucetAddress: public Tezos address of faucet

  • viewer: URL of a block explorer that displays operation detail like http://viewer-url.com/{tx_hash} (eg. https://ghost.tzstats.com)

4. Deploy

Deploy with Docker using Dockerfile.

Build Docker image:

docker build . -t tezos-faucet

Run Docker image:

docker run -p 8080:8080 tezos-faucet

tezos-faucet's People

Contributors

avysel avatar harryttd avatar nicolasochem avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tezos-faucet's Issues

beacon works but loops forever

When using beacon with kukai, after connecting my wallet and confirming in kukai, I see that the wallet address appears in the faucet UI, but the beaon "establishing connection" dialog stays in the foreground and loops forever. I have to close it using X and then everything works fine. There is probably a callback missing somewhere?

make the two ways of using the faucet more explicit

  • state in plain english: "Fund your Web Wallet" "Fund Any Address"
  • replace the "tz" symbol with "tokens" in the buttons. one tez is implicitely "one mainnet tez". testnet tokens should be referred to as "tokens"

See attached picture

PXL_20220818_235703166

Allow specifying a local tezos address alias

octez-client saves known addresses in three json files in its data dir, by default ~/.tezos-client and in tezos-k8s /var/tezos/client

It would be good to do get-tez alice 1000 and it would read alice's pkh from the client dir (the one containing the pkh, the pk and secret key files should not be read)

faucet says "your tez is on the way" when the backend is down

It should display an error instead.

Also, the link says tzstats.com/undefined. see bottom left of picture.

Screenshot from 2022-08-17 14-00-39

Note that when the backend is up and returns an error (for example, "you have too many tez already"), I get an error in the UI. But when the backend was misconfigured and was returning me a text/html 404 page, then I saw this.

Remove profiles, add glider

Instead of letting people choose between 2 options, we should have a minimum and a maximum value, and also a good default.

People can select more or less. More tez means harder challenges.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.