Skip to content

Commit

Permalink
add getTez instructions on faucet page
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasochem committed Dec 7, 2023
1 parent cfd1e99 commit 95dd35f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 19 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ Currently supported networks include:
- Mondaynet
- Dailynet
- Nairobinet
- Oxfordnet

To add a new network, first check that `@airgap/beacon-sdk` handles it ([check their config on the latest release](https://github.com/airgap-it/beacon-sdk/blob/v4.0.6/packages/beacon-types/src/types/beacon/NetworkType.ts)), then update:

```
npm i @airgap/beacon-sdk
```

And in `Config.tsx`, add the `case` for the new network using `NetworkType`.

### 2. Deploy backend

See https://github.com/oxheadalpha/tezos-faucet-backend
Expand Down
5 changes: 4 additions & 1 deletion src/components/Faucet/FaucetRequestButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ export default function FaucetRequestButton({
disabled,
network,
status,
amount,
setAmount
}: {
address: string
disabled: boolean
network: Network
status: StatusContext
amount: number
setAmount: (amount: number) => void
}) {
const [amount, setAmount] = useState<number>(minTez)
const formattedAmount = formatAmount(amount)

const [isLocalLoading, setLocalLoading] = useState<boolean>(false)
Expand Down
12 changes: 11 additions & 1 deletion src/components/Faucet/FaucetToInputRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ import { Network, StatusContext } from "../../lib/Types"
export default function FaucetToInputRequest({
network,
status,
amount,
setAmount,
inputToAddr,
setInputToAddr
}: {
network: Network
status: StatusContext
amount: number
setAmount: (amount: number) => void
inputToAddr: any
setInputToAddr: any

}) {
const [inputToAddr, setInputToAddr] = useState<string>("")
const [inputClass, setInputClass] = useState<string>("")

const inputId: string = network.name + "-to"
Expand Down Expand Up @@ -54,6 +62,8 @@ export default function FaucetToInputRequest({
disabled={disableButton}
network={network}
status={status}
amount={amount}
setAmount={setAmount}
/>
</>
)
Expand Down
10 changes: 10 additions & 0 deletions src/components/Faucet/FaucetToWalletRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ function FaucetToWalletRequest({
user,
network,
status,
amount,
setAmount,
inputToAddr,
setInputToAddr
}: {
user: UserContext
network: Network
status: StatusContext
amount: number
setAmount: (amount: number) => void
inputToAddr: any
setInputToAddr: any
}) {
return (
<>
Expand All @@ -21,6 +29,8 @@ function FaucetToWalletRequest({
disabled={!user.userAddress || status.isLoading}
network={network}
status={status}
amount={amount}
setAmount={setAmount}
/>
</>
)
Expand Down
39 changes: 24 additions & 15 deletions src/components/Faucet/SplittedFaucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Config from "../../Config"

import { Network, UserContext, StatusContext } from "../../lib/Types"

const { minTez, maxTez } = Config.application
export default function SplittedFaucet({
network,
user,
Expand All @@ -27,6 +28,8 @@ export default function SplittedFaucet({
const [showInfo, setShowInfo] = useState(
localStorage.getItem("showInfo") !== "false"
)
const [amount, setAmount] = useState<number>(minTez)
const [inputToAddr, setInputToAddr] = useState<string>("")

const unsetStatus = () => (setStatus(""), setStatusType(""))

Expand Down Expand Up @@ -79,13 +82,24 @@ export default function SplittedFaucet({
network={network}
user={user}
status={statusContext}
amount={amount}
setAmount={setAmount}
inputToAddr={inputToAddr}
setInputToAddr={setInputToAddr}
/>
</Col>
<Col md={6} className="faucet-part">
<Card.Text className="faucet-part-title">
Fund any address
</Card.Text>
<FaucetToInputRequest network={network} status={statusContext} />
<FaucetToInputRequest
network={network}
status={statusContext}
amount={amount}
setAmount={setAmount}
inputToAddr={inputToAddr}
setInputToAddr={setInputToAddr}
/>
</Col>
</Row>

Expand Down Expand Up @@ -148,24 +162,19 @@ export default function SplittedFaucet({

<Alert show={showInfo} variant="secondary" className="mt-3">
<p>
To ensure fair distribution of Tez, we've introduced proof of
work challenges. Before you receive your Tez, your browser will
need to solve these challenges. This is an automatic process
that helps us prevent abuse and ensure everyone gets their fair
share.
Tired of captchas? Need to fund a lot of addresses?
</p>
<p>
💡 Try the <a href="https://forum.tezosagora.org/t/programmatic-faucet/5804" target="_blank"><b>get-tez</b></a> command!
</p>
<p>
<code>npx @oxheadalpha/get-tez {inputToAddr || '<your-address>'} --amount {amount} --network {network.name.toLowerCase()}</code>
</p>
<p>
The number and difficulty of these challenges depends on the
amount of Tez you request. The more Tez you ask for, the higher
the difficulty and the more challenges your browser will need to
solve. This means it might take a bit longer to receive your Tez
if you request a larger amount.
You can also request tokens with the <a href="https://www.npmjs.com/package/@oxheadalpha/get-tez" target="_blank">get-tez NodeJS library</a> or directly through the <a href="https://github.com/oxheadalpha/tezos-faucet-backend#api-endpoints" target="_blank">API</a>.
</p>
<p>
Don't worry, your browser will automatically solve these
challenges. All you need to do is leave your window open and
wait a little while for the process to complete before you
receive your Tez.
Note: to prevent abuse, tokens are granted more slowly when using this method.
</p>

<hr />
Expand Down

0 comments on commit 95dd35f

Please sign in to comment.