> For the complete documentation index, see [llms.txt](https://ringprotocol.gitbook.io/ring/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ringprotocol.gitbook.io/ring/docs/how-to-get-a-fewtoken-address-via-fewfactory.md).

# How to Get a FewToken Address via FewFactory

📘 Example Guide: How to Get a FewToken Address via FewFactory

In Ring Swap, all tokens used in liquidity pools and swaps are wrapped tokens (FewTokens). To maintain compatibility with Uniswap V2 across multiple blockchain networks, Ring Protocol introduces a wrapping layer called Few Protocol. This layer ensures that all original ERC20 tokens are wrapped into their respective FewToken counterparts before being added to liquidity pools or used in swaps.

***

### 🧩 Why FewTokens?

* All tokens in Ring Swap are wrapped ERC20 tokens (FewTokens).
* When quoting token prices or building a swap path, you must use the FewToken address, not the original token.
* Before using any token with Ring Swap, you must either:
  * Wrap the original token into its FewToken version, or
  * Fetch the FewToken address from FewFactory.

***

### 🔍 How to Fetch FewToken Address Using FewFactory

#### 📘 FewFactory Interface

```
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IFewFactory {
    event WrappedTokenCreated(address indexed originalToken, address wrappedToken, uint);

    function getWrappedToken(address originalToken) external view returns (address wrappedToken);
    function allWrappedTokens(uint) external view returns (address wrappedToken);
    function parameter() external view returns (address);
    function allWrappedTokensLength() external view returns (uint);
    function paused() external view returns (bool);
    function createToken(address originalToken) external returns (address wrappedToken);
}
```

#### 🛠 Example: Solidity Code to Query FewToken

```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

interface IFewFactory {
    function getWrappedToken(address originalToken) external view returns (address);
}

contract FewTokenHelper {
    address public fewFactory;

    constructor(address _fewFactory) {
        fewFactory = _fewFactory;
    }

    function getFewTokenAddress(address originalToken) external view returns (address wrappedToken) {
        return IFewFactory(fewFactory).getWrappedToken(originalToken);
    }
}
```

🧪 Use Case: Building a Swap Path

Suppose you want to swap from tokenA → USDC → tokenB via Ring Swap:

1. Query FewTokens for each token:

```
fwTokenA = FewFactory.getWrappedToken(tokenA);
fwUSDC = FewFactory.getWrappedToken(USDC);
fwTokenB = FewFactory.getWrappedToken(tokenB);
```

2. Construct the path:

```
path = [fwTokenA, fwUSDC, fwTokenB];
```

3. Use the path with the Ring Swap router:

```
function swapExactTokensForTokens(
    uint amountIn,
    uint amountOutMin,
    address[] calldata path, // must be FewTokens
    address to,
    uint deadline
) external returns (uint[] memory amounts);
```

✅ Summary

* Always use FewToken addresses in any interaction with Ring Swap (swaps, quotes, liquidity).
* Use FewFactory to resolve the FewToken address of any original ERC20 token.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ringprotocol.gitbook.io/ring/docs/how-to-get-a-fewtoken-address-via-fewfactory.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
