# Pair Addresses

## **get\_pair**

The best way to get the address for a pair is to call [get\_pair](/for-developers/jediswap-v1/smart-contract-reference/factory.md#get_pair) on the [Factory](/for-developers/jediswap-v1/smart-contract-reference/factory.md). If the pair exists, this function will return its address else 0

* The "canonical" way to determine whether or not a pair exists.
* Requires an on-chain lookup.

## **Off-Chain**

Python Example:

```python
from starkware.starknet.core.os.contract_address.contract_address import calculate_contract_address_from_hash
from starkware.cairo.lang.vm.crypto import pedersen_hash


def get_create2_address(token0: int, token1: int, class_hash: int) -> int:

    salt = pedersen_hash(token0, token1)

    constructor_calldata = [token0,
                            token1]

    create2_pair_address = calculate_contract_address_from_hash(
        salt=salt, class_hash=class_hash, deployer_address=factory, constructor_calldata=constructor_calldata)

    return create2_pair_address
```

* token0 must be strictly less than token1 by sort order.
* Can be computed offline.
* Requires the ability to perform pedersen\_hash.


---

# Agent Instructions: 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:

```
GET https://docs.jediswap.xyz/for-developers/jediswap-v1/smart-contract-integration/pair-addresses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
