> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.chainstack.com/feedback

```json
{
  "path": "/recipes",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Recipes

> Ready-to-use code snippets for common blockchain development tasks, covering Ethereum, Solana, Polygon, and other networks with Chainstack endpoints.

export const Button = ({href, children}) => {
  return <div className="not-prose group mt-3">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-xl group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
      </button>
    </a>
  </div>;
};

<CardGroup>
  <Card title="Create a .env file with all your Chainstack endpoints with Python" icon="globe" iconType="solid" href="/recipes/create-a-env-file-with-all-your-chainstack-endpoints-with-python">
    Learn how to automatically generate a .env file listing all your Chainstack endpoints with Python.

    13 Steps

    <Button href="/recipes/create-a-env-file-with-all-your-chainstack-endpoints-with-python">Open Recipe</Button>
  </Card>

  <Card title="How to get ERC-20 token transfer logs using ethers.js" icon="books" iconType="solid" href="/recipes/how-to-get-erc-20-token-transfer-logs-using-ethersjs">
    This recipe shows you how to use the Ethers library with a Chainstack Ethereum node to retrieve transfer logs for an ERC-20 token.

    7 Steps

    <Button href="/recipes/how-to-get-erc-20-token-transfer-logs-using-ethersjs">Open Recipe</Button>
  </Card>

  <Card title="Extract 'randao' value from the Ethereum Beacon chain using the block details method" icon="code" iconType="solid" href="/recipes/extract-randao-value-from-the-ethereum-beacon-chain-using-the-block-details-method-1">
    This script extracts the 'randao' information from the Beacon chain block details in JavaScript using the Axios package.

    6 Steps

    <Button href="/recipes/extract-randao-value-from-the-ethereum-beacon-chain-using-the-block-details-method-1">Open Recipe</Button>
  </Card>

  <Card title="Identify if a block has been included in the main chain or was forked" icon="magnifying-glass" iconType="solid" href="/recipes/identify-if-a-block-has-been-included-in-the-main-chain-or-was-forked-1">
    This script uses web3.js to evaluate whether a specific block within a blockchain network has been integrated into the main chain or if it was a result of a reorg.

    6 Steps

    <Button href="/recipes/identify-if-a-block-has-been-included-in-the-main-chain-or-was-forked-1">Open Recipe</Button>
  </Card>

  <Card title="How to properly encode topics for eth_getLogs" icon="robot" iconType="solid" href="/recipes/how-to-properly-encode-topics-for-eth_getlogs-1">
    These web3.js and ethers.js scripts provide a straightforward way to generate encoded event signatures and parameters that can be utilized in the topics filter when pulling logs from an EVM-compatible chain.

    7 Steps

    <Button href="/recipes/how-to-properly-encode-topics-for-eth_getlogs-1">Open Recipe</Button>
  </Card>

  <Card title="How to encode callData parameters to programmatically interact with a smart contract" icon="file-lines" iconType="solid" href="/recipes/how-to-encode-calldata-parameters-to-programmatically-interact-with-a-smart-contract">
    These scripts show you how to encode callData parameters using the Ethereum ABI specification and web3.js to interact with smart contracts programmatically.

    7 Steps

    <Button href="/recipes/how-to-encode-calldata-parameters-to-programmatically-interact-with-a-smart-contract">Open Recipe</Button>
  </Card>

  <Card title="How to convert decimal numbers to hexadecimals strings using web3.js and ethers.js" icon="laptop" iconType="solid" href="/recipes/how-to-convert-decimal-numbers-to-hexadecimals-strings-using-web3js-and-ethersjs">
    Hexadecimal strings are used to represent addresses and encode gas data and values. These scripts show you how to do it programmatically within your DApps.

    4 Steps

    <Button href="/recipes/how-to-convert-decimal-numbers-to-hexadecimals-strings-using-web3js-and-ethersjs">Open Recipe</Button>
  </Card>

  <Card title="Send batch requests using ethers.js" icon="medal" iconType="solid" href="/recipes/send-batch-requests-using-ethersjs">
    This Recipe shows how to send batch requests to your Chainstack node instead of sending multiple loop-based requests. Adopting this approach can substantially boost the performance of your DApp.

    7 Steps

    <Button href="/recipes/send-batch-requests-using-ethersjs">Open Recipe</Button>
  </Card>

  <Card title="Send simultaneous blockchain requests using web3.js" icon="money-bill-wave" iconType="solid" href="/recipes/send-simultaneous-blockchain-requests-using-web3js">
    This Recipe shows you how to efficiently send multiple requests to an Ethereum node instead of using a `for` loop by fetching an account balance for the past 500 blocks.

    6 Steps

    <Button href="/recipes/send-simultaneous-blockchain-requests-using-web3js">Open Recipe</Button>
  </Card>

  <Card title="Monitor incoming transactions to an Ethereum address in real time using subscriptions and web3.js" icon="envelope" iconType="solid" href="/recipes/monitor-incoming-transactions-to-an-ethereum-address-in-real-time-using-subscriptions-and-web3js">
    This Recipe shows you how to leverage subscriptions, WSS endpoints, and web3.js to monitor incoming transactions in real-time.

    5 Steps

    <Button href="/recipes/monitor-incoming-transactions-to-an-ethereum-address-in-real-time-using-subscriptions-and-web3js">Open Recipe</Button>
  </Card>

  <Card title="Send Solana transactions using solana/web3.js" icon="chart-line" iconType="solid" href="/recipes/send-solana-transactions-using-solanaweb3js">
    This Recipe shows how you can use the solana/web3.js library to send transactions programmatically.

    7 Steps

    <Button href="/recipes/send-solana-transactions-using-solanaweb3js">Open Recipe</Button>
  </Card>

  <Card title="Fetching contract deployment transactions with the Chainstack Covalent SDK" icon="laptop" iconType="solid" href="/recipes/fetching-contract-deployment-transactions-with-the-chainstack-covalent-sdk">
    Querying the Chainstack Covalent SDK to return a list of contracts deployed by a specified address.

    7 Steps

    <Button href="/recipes/fetching-contract-deployment-transactions-with-the-chainstack-covalent-sdk">Open Recipe</Button>
  </Card>

  <Card title="Monitoring swaps on Uniswap with WebSocket endpoints" icon="unicorn" iconType="solid" href="/recipes/monitoring-swaps-on-uniswap-with-websocket-endpoints">
    Monitoring swaps, in near real-time, as they happen on Uniswap V2 with web3.js.

    7 Steps

    <Button href="/recipes/monitoring-swaps-on-uniswap-with-websocket-endpoints">Open Recipe</Button>
  </Card>

  <Card title="Querying subgraphs in Python with Subgrounds" icon="chart-line" iconType="solid" href="/recipes/querying-subgraphs-in-python-with-subgrounds">
    Leveraging the Subgrounds Python library to interact with subgraphs.

    6 Steps

    <Button href="/recipes/querying-subgraphs-in-python-with-subgrounds">Open Recipe</Button>
  </Card>

  <Card title="Minting SPL tokens with solana-web3.js" icon="medal" iconType="solid" href="/recipes/minting-spl-tokens-with-solana-web3js">
    Leveraging solana-web3.js and spl-token to mint 1000 SPL tokens on Solana.

    7 Steps

    <Button href="/recipes/minting-spl-tokens-with-solana-web3js">Open Recipe</Button>
  </Card>

  <Card title="Simulate a buy swap on Uniswap using Web3.js" icon="money-bill-trend-up" iconType="solid" href="/recipes/simulate-a-buy-swap-on-uniswap-using-web3js">
    Learn how to use `eth_call` to simulate Uniswap swaps.

    7 Steps

    <Button href="/recipes/simulate-a-buy-swap-on-uniswap-using-web3js">Open Recipe</Button>
  </Card>

  <Card title="Delegating SOL with solana-web3.js" icon="lock" iconType="solid" href="/recipes/delegating-sol-with-solana-web3js">
    Using solana-web3.js to interact with Solana's stake program to delegate 0.02 SOL.

    6 Steps

    <Button href="/recipes/delegating-sol-with-solana-web3js">Open Recipe</Button>
  </Card>

  <Card title="Fetching Polygon Logs for an Address from a Block using `eth_getTransactionReceiptsByBlock` and web3.py" icon="globe" iconType="solid" href="/recipes/fetching-polygon-logs-for-an-address-from-a-block-using-eth_gettransactionreceiptsbyblock-and-web3py">
    Using the web3.py library, this tool fetches transaction logs from the Polygon blockchain for a given Ethereum address in a specific block. It aids in efficient retrieval and analysis of transaction activities, ideal for debugging and monitoring.

    11 Steps

    <Button href="/recipes/fetching-polygon-logs-for-an-address-from-a-block-using-eth_gettransactionreceiptsbyblock-and-web3py">Open Recipe</Button>
  </Card>

  <Card title="Create a .env file with all your Chainstack endpoints with JavaScript" icon="computer" iconType="solid" href="/recipes/create-a-env-file-with-all-your-chainstack-endpoints-with-javascript">
    Learn how to create a `.env` file with all your Chainstack endpoints using JavaScript.

    7 Steps

    <Button href="/recipes/create-a-env-file-with-all-your-chainstack-endpoints-with-javascript">Open Recipe</Button>
  </Card>

  <Card title="How to transfer the entire account balance using web3.js" icon="scale-balanced" iconType="solid" href="/recipes/how-to-transfer-the-entire-account-balance-using-web3js">
    Learn how to transfer the entire balance from an account using web3.js.

    5 Steps

    <Button href="/recipes/how-to-transfer-the-entire-account-balance-using-web3js">Open Recipe</Button>
  </Card>

  <Card title="Fetch ERC-20 balances using ethers.js and ChainstackProvider" icon="chart-line" iconType="solid" href="/recipes/fetch-erc-20-balances-using-ethersjs-and-chainstackprovider">
    Use ethers with the `ChainstackProvider` to call smart contract functions.

    7 Steps

    <Button href="/recipes/fetch-erc-20-balances-using-ethersjs-and-chainstackprovider">Open Recipe</Button>
  </Card>
</CardGroup>
