.gitpod.yml
.travis.yml
README.md
contract-rs
    Cargo.toml
    README.md
    build.sh
    src
        lib.rs
frontend
    README.md
    package.json
    public
        index.html
        manifest.json
        robots.txt
    src
        App.js
        App.test.js
        index.js
        setupTests.js

# Account faucet with Proof of Work

A Faucet contract that creates and funds accounts if the caller provides basic proof of work
to avoid sybil attacks and draining balance too fast.

The new account always receives 1/1000 of the remaining balance.

Proof of Work works the following way:

You need to compute a u64 salt (nonce) for a given account and a given public key in such a way
that the `sha256(account_id + ':' + public_key + ':' + salt)` has more leading zero bits than
the required `min_difficulty`.

## Testing
To test run:
```bash
cargo test
```
Proof of Work Transfer Faucet
=============================

<!-- MAGIC COMMENT: DO NOT DELETE! Everything above this line is hidden on NEAR Examples page -->

Try it out: https://near-examples.github.io/token-printer/

It consists of 2 parts:

## Transfer Faucet contract

A Faucet contract allows to transfer tokens to a desired account for doing required Proof of Work.
This contract is based on PoW faucet example: https://github.com/near-examples/pow-faucet

The transfer amount is set to 100N tokens. It's enough to deploy a 1Mb contract.

Proof of Work works the following way:

You need to compute a u64 salt (nonce) for a given account in such a way
that the `sha256(account_id + ':' + salt)` has at the amount of leading zero bits as
the required `min_difficulty`. The hash has to be unique in order to receive transfer.
One account can request multiple transfers.

## Faucet frontend

Allows to enter the account ID to receive transfer. And it computes the Proof of Work required by the contract using front-end JS.

https://near-examples.github.io/token-printer/

## Testing
To test run:
```bash
cargo test
```
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `yarn deploy`

Deploys app to github pages.<br />

### `yarn test`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
