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

# NFT Minting (Ethereum)

Mint an NFT by calling a smart contract's mint function with the embedded wallet.

## Implementation

```tsx theme={null}
import { useSendTransaction } from '@moon-key/react-auth/ethereum';
import { encodeFunctionData } from 'viem';

const NFT_MINT_ABI = [
  {
    name: 'mint',
    type: 'function',
    stateMutability: 'payable',
    inputs: [{ name: 'quantity', type: 'uint256' }],
    outputs: []
  }
] as const;

export default function MintNFT() {
  const { sendTransaction } = useSendTransaction();

  const handleMint = async () => {
    const nftContractAddress = '0x...'; // Your NFT contract
    const mintPrice = '10000000000000000'; // 0.01 ETH in wei

    try {
      const data = encodeFunctionData({
        abi: NFT_MINT_ABI,
        functionName: 'mint',
        args: [1n] // Mint 1 NFT
      });

      const txHash = await sendTransaction({
        to: nftContractAddress,
        value: mintPrice,
        data
      });

      console.log('NFT minted:', txHash);
    } catch (error) {
      console.error('Minting failed:', error);
    }
  };

  return (
    <div>
      <h2>Mint NFT</h2>
      <button onClick={handleMint}>Mint NFT (0.01 ETH)</button>
    </div>
  );
}
```

## Key concepts

* **Payable function** - The mint function accepts ETH (specified in `value`)
* **Function encoding** - Encodes the mint function call with quantity parameter
* **Value in wei** - ETH amount must be specified in wei (1 ETH = 10^18 wei)
* **Contract call** - Sends transaction to NFT contract with both value and data

## Common patterns

### Dynamic quantity

```tsx theme={null}
const [quantity, setQuantity] = useState(1);

const handleMint = async () => {
  const data = encodeFunctionData({
    abi: NFT_MINT_ABI,
    functionName: 'mint',
    args: [BigInt(quantity)]
  });

  const txHash = await sendTransaction({
    to: nftContractAddress,
    value: (parseFloat(mintPrice) * quantity).toString(),
    data
  });
};
```

### With status tracking

```tsx theme={null}
const [mintStatus, setMintStatus] = useState<'idle' | 'minting' | 'success' | 'error'>('idle');

const handleMint = async () => {
  setMintStatus('minting');
  try {
    await sendTransaction({...});
    setMintStatus('success');
  } catch (error) {
    setMintStatus('error');
  }
};
```

## Important notes

<Warning>
  Make sure the user has sufficient ETH balance to cover both the mint price and gas fees.
</Warning>

<Info>
  The ABI should match your NFT contract's mint function signature. Common variations include `mint()`, `mint(uint256 quantity)`, or `mint(address to, uint256 quantity)`.
</Info>

## Next steps

<CardGroup cols={2}>
  <Card title="Solana Programs" icon="bolt" href="/recipes/solana-program-interaction">
    Interact with Solana programs
  </Card>

  <Card title="Multi-Step Flow" icon="list-check" href="/recipes/multi-step-transaction-flow">
    Handle complex transaction flows
  </Card>
</CardGroup>
