<!DOCTYPE html>
<html>
<head>
<title>Tron Faucet</title>
</head>
<body>
<h1>Tron Faucet</h1>
<form id="claim-form">
<label for="address">Tron Wallet Address:</label>
<input type="text" id="address" name="address" required><br><br>
<input type="submit" value="Claim TRX">
</form>
<div id="result"></div>
<script>
document.getElementById("claim-form").addEventListener("submit", function (event) {
event.preventDefault();
// Get the Tron wallet address from the form
var tronAddress = document.getElementById("address").value;
// You would need to replace 'your_api_key' with your FaucetPay API key
var apiKey = 'your_api_key';
// Make an API request to FaucetPay to send TRX to the user's address
fetch('https://faucetpay.io/api/v1/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + apiKey
},
body: JSON.stringify({
currency: 'TRX',
to: tronAddress,
amount: 1 // The amount of TRX to send
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Display a success message
document.getElementById("result").innerHTML = "TRX sent successfully!";
} else {
// Display an error message
document.getElementById("result").innerHTML = "Error: " + data.message;
}
})
.catch(error => {
// Display an error message if the request fails
document.getElementById("result").innerHTML = "An error occurred: " + error.message;
});
});
</script>
</body>
</html>
Post a Comment