# Programmatic Faucet

**URL:** https://forum.tezosagora.org/t/programmatic-faucet/5804
**Category:** Project Updates
**Created:** [October 12, 2023, 3:00pm UTC](https://forum.tezosagora.org/t/programmatic-faucet/5804 "2023-10-12T15:00:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![harar](https://forum.tezosagora.org/user_avatar/forum.tezosagora.org/harar/32/1984_2.png) [@harar](https://forum.tezosagora.org/u/harar)
#### Post date: [October 12, 2023, 3:00pm UTC](https://forum.tezosagora.org/t/programmatic-faucet/5804/1 "2023-10-12T15:00:38Z")

</div>

# Programmatic Faucet

We have deployed some updates to the [Teztnets](https://teztnets.xyz/) platform that include a long-requested feature: the programmatic faucet.

With the npm package [`@oxheadalpha/get-tez`](https://www.npmjs.com/package/@oxheadalpha/get-tez), you can now programatically fund an address using Javascript/Typescript or using the CLI. See the package details for more for info on installing and using.

## Proof of Work

To prevent spam, we’ve also introduced the need to solve PoW challenges before receiving your Tez. The number of challenges given depends on the network and the amount of Tez requested. Less challenges are required when requesting Tez via a faucet’s web interface compared to when doing so programmatically.

It is relatively easy to get large amount of Tez on an ephemeral network such as mondaynet and dailynet. Meanwhile, ghostnet is getting large (600Gi for an archive node) and we want to keep this network useful for some time. Therefore we made getting tokens for this network just a little bit harder - you have to crunch numbers for approximately one hour to get enough Tez to become a ghostnet baker.

## Usage

Using the package is as simple as the following:

JS/TS:

```ts
import getTez from "@oxheadalpha/get-tez"

(async () => {
    const txHash = await getTez({
      address: "tz1...",
      amount: 10,
      network: "ghostnet",
    })
    // txHash: ooaEskbj...
})()

```

CLI:

```auto
npx @oxheadalpha/get-tez tz1... --amount 10 --network ghostnet

```

  

_Special thanks to Nicolas Ochem_

---

<div class="post-metadata">

### Author: ![zamrokk](https://forum.tezosagora.org/user_avatar/forum.tezosagora.org/zamrokk/32/1634_2.png) [@zamrokk](https://forum.tezosagora.org/u/zamrokk)
#### Post date: [October 12, 2023, 3:20pm UTC](https://forum.tezosagora.org/t/programmatic-faucet/5804/2 "2023-10-12T15:20:06Z")

</div>

> [@harar](#):
>
> for some time. Therefore we made getting tokens for this network just a little bit harder - you have to crunch numbers for approximately one hour to get enough Tez to become a ghostnet baker.

If I resume : you opened an API on your backend to give free tez  
Is it correct ?

---

<div class="post-metadata">

### Author: ![harar](https://forum.tezosagora.org/user_avatar/forum.tezosagora.org/harar/32/1984_2.png) [@harar](https://forum.tezosagora.org/u/harar)
#### Post date: [October 13, 2023, 7:55pm UTC](https://forum.tezosagora.org/t/programmatic-faucet/5804/3 "2023-10-13T19:55:56Z")

</div>

Yes, please see the the Tezos Faucet Backend readme’s [API Endpoints](https://github.com/oxheadalpha/tezos-faucet-backend/tree/2.2.0#api-endpoints) section for more information.

---

<div class="post-metadata">

### Author: ![mweichert](https://forum.tezosagora.org/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@mweichert](https://forum.tezosagora.org/u/mweichert)
#### Post date: [October 13, 2023, 8:29pm UTC](https://forum.tezosagora.org/t/programmatic-faucet/5804/4 "2023-10-13T20:29:33Z")

</div>

> With the npm package [`@oxheadalpha/get-tez`](https://www.npmjs.com/package/@oxheadalpha/get-tez), you can now programatically fund an address using Javascript/Typescript or using the CLI.

Awesome! We’ll ensure that Taqueria makes use of this in an upcoming update.

Thanks for the great work.

Cheers.

---

<div class="post-metadata">

### Author: ![harar](https://forum.tezosagora.org/user_avatar/forum.tezosagora.org/harar/32/1984_2.png) [@harar](https://forum.tezosagora.org/u/harar)
#### Post date: [October 19, 2023, 1:51am UTC](https://forum.tezosagora.org/t/programmatic-faucet/5804/5 "2023-10-19T01:51:19Z")

</div>

Update: You can now provide a local address alias instead of a raw public key hash! See the [readme](https://github.com/oxheadalpha/tezos-faucet/blob/main/getTez/README.md) for more details.

JS:

```js
const txHash = await getTez({
  address: "alice",
  amount: 10,
  network: "ghostnet",
})

```

CLI:  
`npx @oxheadalpha/get-tez@latest alice -a 1 -n ghostnet`.

```shell
❯ npx @oxheadalpha/get-tez@latest --help
CLI Usage: npx @oxheadalpha/get-tez [options] <address>

<address>:
  The address where Tez should be sent. This can be either a standard Tezos public key hash (e.g. tz1234abc...)
  or a local alias. If an alias is provided (e.g., 'alice'), the program will attempt to resolve it to a public
  key hash by looking it up in the specified client directory (set by --client-dir or by the TEZOS_CLIENT_DIR
  environment variable). If neither is set, the default lookup location is $HOME/.tezos-client/public_key_hashes.
...

```
