A simple web application with a backend for a Monero testnet faucet. It provides a web UI and an API endpoint to request testnet XMR.
Examples:
- Node.js
- A running
monero-wallet-rpcinstance with a funded testnet wallet.
- Clone the repository:
git clone https://github.com/kic0/FCMP--Testnet-Faucet cd FCMP--Testnet-Faucet - Install dependencies:
npm install
You need a testnet wallet with some funds. First, create a directory for your wallets (e.g., /home/user/monero-wallets). Then, start the RPC server, pointing it to that directory:
monero-wallet-rpc \
--rpc-bind-port 28088 \
--wallet-dir /home/user/monero-wallets \
--password your-wallet-password \
--rpc-login monero:rpcPassword \
--testnet \
--log-file logs/monero-wallet-rpc.log \
--non-interactiveNote: Your faucet wallet file (e.g., faucet-wallet) must be located inside the directory specified by --wallet-dir. You may need to create this wallet first using monero-wallet-cli and move it there.
The backend server is configured using environment variables. Before running the server, you must set the following variables.
export RPC_USER="monero"
export RPC_PASSWORD="rpcPassword"
# This must be the FILENAME of the wallet inside the wallet-dir
export WALLET_FILE="faucet-wallet"
export WALLET_PASSWORD="your-wallet-password"
# Optional, defaults are shown:
# export RPC_HOST="127.0.0.1"
# export RPC_PORT="28088"-
Start the server:
npm start
The server will start and be accessible at
http://<your-server-ip>:3000. -
Use the Web Interface: Open your web browser and navigate to
http://<your-server-ip>:3000(or your server's IP address if running remotely). The current faucet balance is displayed at the top. Enter your testnet wallet address and click the "Request 1 XMR" button to receive funds.
The API provides two endpoints:
GET /faucet/balance: Fetches the current balance of the faucet wallet.POST /faucet/send: Sends funds to a specified address.
Example using curl to send funds:
curl -X POST -H "Content-Type: application/json" \
-d '{"address": "YOUR_TESTNET_WALLET_ADDRESS", "amount": "1"}' \
http://0.0.0.0:3000/faucet/sendA successful request will return a JSON response like this:
{
"success": true,
"message": "Sent 1 XMR to YOUR_TESTNET_WALLET_ADDRESS",
"txHash": "a_transaction_hash"
}This is a proof-of-concept and should be used for testing purposes only. Ensure your monero-wallet-rpc is not exposed to the public internet without proper security measures.
This code was generated using an AI.
If for some reason you feel like donating 46hHveE5bAQHv6AE9bbYSJMsJupA2je1BFBUYLmMp899i2yMC8MEn35QiUEZiS2Scd5QGKFrcDk5yZCxL91Rtm9FAz44MMA