Get tokens

Chainstack API method to request Ethereum or BNB Smart Chain Testnet funds. Developers use testnet funds for various purposes, primarily to test and develop decentralized applications (DApps), smart contracts, and other blockchain-based projects within a safe and controlled environment.

πŸ“˜

You can also request funds directly from the Chainstack Faucet page.

Path parameters

  • chain β€” the test network you want to receive funds on.
    • sepolia β€” receive testnet ETH on Sepolia.
    • goerliβ€” receive testnet ETH on Goerli.
    • holesky β€” receive testnet ETH on Holesky.
    • bnb-testnet β€” receive testnet BNB.
    • zksync-testnet β€” receive testnet ETH on zkSync Goerli.
    • scroll-sepolia-testnet β€” receive testnet ETH on Scroll Sepolia.

🚧

Spam protection system

Note that this API integrates a strict spam protection system, although it should not be required for most requests, be ready to hold a balance on Mainnet to prevent abuse.

If our system identifies potential abuse, it will require the account calling the faucet to hold a minimum of 0.002 ETH on Mainnet. This measure helps ensure fair usage and prevent exploitation of the service.

πŸ“˜

Faucet API base URL

https://api.chainstack.com/v1/faucet/{chain}

Body parameters

  • address β€” the address that will receive the funds.

Response

  • urlβ€” the block explorer URL, including the transaction hash, to monitor the status.

Request funds from this page

You can already try this API from this page by doing the following:

  1. Get your API key and paste it into the Bearer field in the AUTHENTICATION section.
  2. At the bottom of the page, select which network you want to receive funds from.
  3. At the bottom of the page, paste your Ethereum address in the address field.

Code examples

The Faucet API is a great option for developers who don't want to spend time hunting for testnet tokens.

Here's an example of a script that automatically refills your wallet by calling the Chainstack Faucet API every 24 hours, ensuring a seamless daily refill.

// npm i axios

const axios = require('axios');

// API config
const chain = 'sepolia' // goerli
const address = 'YOUR_ADDRESS';

const apiUrl = `https://api.chainstack.com/v1/faucet/${chain}`;
const apiKey = 'YOUR_CHAINSTACK_API_KEY';

const fillWallet = async () => {
    console.log(`Sending faucet request for address ${address}`)
  try {
    const response = await axios.post(apiUrl, { address }, {
      headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json',
      },
    });

    console.log('API call successful:', response.data);
  } catch (error) {
    console.error('Error making API call:', error.response.data);
  }

  // Schedule the next API call in 24 hours (24 * 60 * 60 * 1000 milliseconds)
  setTimeout(makeApiCall, 24 * 60 * 60 * 1000);
};

// Make the first API call immediately
fillWallet();

# pip install requests

import requests
import time

# API config
chain = 'sepolia'  # goerli
address = 'YOUR_ADDRESS'

api_url = f'https://api.chainstack.com/v1/faucet/{chain}'
api_key = 'YOUR_CHAINSTACK_API_KEY'


def fill_wallet():
    print(f'Sending faucet request for address {address}')
    try:
        response = requests.post(
            api_url,
            json={'address': address},
            headers={
                'Authorization': f'Bearer {api_key}',
                'Content-Type': 'application/json',
            },
        )

        print('API call successful:', response.json())
    except Exception as error:
        print('Error making API call:', error)

    # Schedule the next API call in 24 hours (24 * 60 * 60 seconds)
    time.sleep(24 * 60 * 60)


# Make the first API call immediately
while True:
    fill_wallet()

Use cases

Here are some use cases testnet funds are used for:

  • Smart contract development β€” with testnet funds, developers can deploy and interact with smart contracts, finding and fixing any issues before moving to the mainnet, where the real money is involved.
  • Testing DApps and infrastructure β€” testnet funds allow developers to try out transactions, see how user interfaces work, and check the overall functionality of their DApps and blockchain components without risking real assets.
  • Trying out new features β€” testnets are perfect for exploring and testing new features or updates to blockchain protocols and applications. It's like a sandbox where developers can play around and validate their ideas before taking them live on the mainnet.
  • Stress testing and scalability β€” developers use testnet funds to put their DApps or smart contracts through the wringer, seeing how they perform under various conditions and loads. This helps them spot any issues and fix them before going live.
  • Learning and training β€” testnet funds create a risk-free space for developers, researchers, and enthusiasts to learn about blockchain technology, smart contracts, and DApps. It's a great way to build expertise and understanding in the field.
Language
Authorization
Bearer
Click Try It! to start a request and see the response here!