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

# Stake

> Deposit STRK to earn staking rewards

## Overview

Generates transaction calls to stake STRK tokens in a validator pool. Returns calls that you execute to deposit tokens and start earning rewards.

## Path Parameters

<ParamField path="poolAddress" type="string" required>
  Pool contract address
</ParamField>

<ParamField path="userAddress" type="string" required>
  User's wallet address
</ParamField>

## Request

<ParamField body="userAddress" type="string" required>
  User's wallet address
</ParamField>

<ParamField body="amount" type="string" required>
  Amount of STRK to stake (hex format)
</ParamField>

## Response

<ResponseField name="chainId" type="string" required>
  Network identifier
</ResponseField>

<ResponseField name="calls" type="array" required>
  Transaction calls to execute

  <Expandable title="Call Object">
    <ResponseField name="contractAddress" type="string">
      Contract address
    </ResponseField>

    <ResponseField name="entrypoint" type="string">
      Function name
    </ResponseField>

    <ResponseField name="calldata" type="array">
      Call arguments
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://starknet.api.avnu.fi/staking/v3/pools/0x123abc/members/0x0456def/stake" \
    -H "Content-Type: application/json" \
    -d '{
      "userAddress": "0x0456def...",
      "amount": "0xde0b6b3a7640000"
    }'
  ```

  ```typescript TypeScript theme={null}
  async function stakeStrk(poolAddress: string, amount: string, account: Account) {
    // 1. Get staking calls
    const response = await fetch(
      `https://starknet.api.avnu.fi/staking/v3/pools/${poolAddress}/members/${account.address}/stake`,
      {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          userAddress: account.address,
          amount
        })
      }
    );

    const { calls } = await response.json();

    // 2. Execute transaction
    const tx = await account.execute(calls);

    // 3. Wait for confirmation
    await account.waitForTransaction(tx.transaction_hash);

    return tx.transaction_hash;
  }

  // Usage
  const txHash = await stakeStrk(
    '0x123abc',
    '0xde0b6b3a7640000', // 1 STRK in hex
    account
  );
  ```

  ```python Python theme={null}
  from starknet_py.net.account.account import Account
  import requests

  async def stake_strk(pool_address: str, amount: str, account: Account):
      # Get calls
      response = requests.post(
          f'https://starknet.api.avnu.fi/staking/v3/pools/{pool_address}/members/{account.address}/stake',
          json={
              'userAddress': account.address,
              'amount': amount
          }
      )

      calls = response.json()['calls']

      # Execute
      tx = await account.execute(calls)
      await account.wait_for_tx(tx.transaction_hash)

      return tx.transaction_hash
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "chainId": "0x534e5f4d41494e",
    "calls": [
      {
        "contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
        "entrypoint": "approve",
        "calldata": ["0x123abc", "0xde0b6b3a7640000", "0"]
      },
      {
        "contractAddress": "0x123abc",
        "entrypoint": "stake",
        "calldata": ["0xde0b6b3a7640000", "0"]
      }
    ]
  }
  ```
</ResponseExample>
