> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/documentation/bsc/aggregator/editor/direct-allowance/native-bnb.md). Agents can also search and read this documentation through its [MCP server](https://docs.peach.ag/~gitbook/mcp).

# Native BNB

Swap native BNB and understand the sentinel address, WBNB and transaction value.

Import `NATIVE_TOKEN_ADDRESS` from `@masterpeach/aggregator-sdk` to identify native BNB. Its value, shown below, is a placeholder rather than an ERC20 contract. `isNativeTokenAddress(address)` recognizes it case-insensitively.

| Asset               | Value used in SDK token parameters           | Handling                                                 |
| ------------------- | -------------------------------------------- | -------------------------------------------------------- |
| Native BNB          | `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` | Native balance; 18 decimals; no ERC20 approval for input |
| WBNB on BSC Mainnet | `0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c` | ERC20 balance and allowance                              |

Pass the sentinel as `from` or `target` when preparing a swap. Read native BNB balance with `provider.getBalance(walletAddress)` and format it with `ethers.formatEther()`. ERC20 helpers such as `getTokenInfo()` and `client.getBalance()` expect token contract addresses; do not pass the sentinel to them or use it as a transaction destination.

`amount` uses input-token base units: 18 decimals for native BNB, or the input ERC20's decimals for token-to-BNB swaps.

### Supported swaps

| Input → output          | Direct Swaps                 | Delegated Swaps |
| ----------------------- | ---------------------------- | --------------- |
| ERC20 → ERC20           | Supported                    | Supported       |
| Native BNB → ERC20      | Supported; no ERC20 approval | Unsupported     |
| ERC20 → Native BNB      | Supported                    | Supported       |
| Native BNB → Native BNB | Rejected                     | Rejected        |

These are SDK capabilities. The selected deployment must also support the mode and have a route.

### Swap BNB

Use the initialized `client` and your signer's address as the executor, as in [Quickstart](https://docs.peach.ag/documentation/bsc/aggregator/quickstart).

```typescript
import { ethers } from "ethers";
import { NATIVE_TOKEN_ADDRESS, PeachClient } from "@masterpeach/aggregator-sdk";

export async function prepareBNBSwap(client: PeachClient, executor: string, tokenOut: string) {
  const prepared = await client.swapAllowance({
    from: NATIVE_TOKEN_ADDRESS,
    target: tokenOut,
    amount: ethers.parseEther("0.01"),
    executor,
    slippageBps: 50, // 0.5%
    deadlineSecs: 300,
  });
  return prepared;
}
```

After preparation, display `prepared.expectAmountOut` and `prepared.tx.amountOutMin` using output-token decimals. Once the user accepts them, follow Quickstart’s approval/submission step; the approval helper returns `undefined` for native input.

For native output, put an ERC20 address in `from` and `NATIVE_TOKEN_ADDRESS` in `target`. Use input-token decimals for the amount. Format BNB output with 18 decimals.

### Addresses and transaction value

The SDK normalizes the sentinel to configured WBNB, so prepared `tokenIn` / `tokenOut` contain WBNB addresses for native requests. Use `nativeMode` to identify the native direction and retain the original sentinel in your order for refreshed preparation. Explicit `nativeIn` or `nativeOut` flags are also supported.

Native mode `0` means ERC20 input/output, `1` means native input, and `2` means native output. For native input the validated transaction value equals prepared input; for other modes it is zero. `executeSwap()` preserves that value.

Do not add BNB to an ERC20-input swap or overwrite `tx.value`. Native input requires enough balance for input plus gas. For ERC20 input, the executor still needs BNB for gas, and any payer approval needs gas in the payer's account.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peach.ag/documentation/bsc/aggregator/editor/direct-allowance/native-bnb.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
