Skip to content

Commit

Permalink
docs(services): add how to use the faucet directly from HTTP (#2067)
Browse files Browse the repository at this point in the history
  • Loading branch information
qbzzt authored Dec 14, 2023
1 parent dce5494 commit 49d4a18
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/pages/services/faucet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ A minimal Typescript faucet to drip native tokens on Ethereum chains

## Getting ETH from a faucet

[This sample program](https://github.com/latticexyz/mud/tree/main/examples/faucet-client) shows how to obtain ETH from a faucet.
[This sample program](https://github.com/latticexyz/mud/tree/main/examples/faucet-client) shows how to obtain ETH from a faucet using TypeScript.

Alternatively, you can submit a `POST` request to the faucet.
For example, if you use the default `HOST` and `PORT`, this command requests a drip to the zero address.

```sh copy
curl -X POST http://127.0.0.1:3002/trpc/drip \
-H "Content-Type: application/json" \
-d '{"address": "0x0000000000000000000000000000000000000000"}'
```
10 changes: 10 additions & 0 deletions examples/faucet-client/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
Drip some ETH from a [faucet](https://mud.dev/services/faucet).

If you can't use TypeScript, you can use

```
curl -X POST http://127.0.0.1:3002/trpc/drip \
-H "Content-Type: application/json" \
-d '{"address": "0x0000000000000000000000000000000000000000"}'
```

or the equivalent
12 changes: 12 additions & 0 deletions examples/faucet-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ const tx = await faucetClient.drip.mutate({
});

console.log(`Transaction hash: ${tx}`);

/*
This call submits a POST request to http://127.0.0.1:3002/trpc/drip
In the header, it has:
Content-Type: application/json
Then, the data is:
{"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3"}
*/

0 comments on commit 49d4a18

Please sign in to comment.