> For the complete documentation index, see [llms.txt](https://tonpay.gitbook.io/tonpay-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tonpay.gitbook.io/tonpay-sdk/python/initialization.md).

# Initialization

Before you can interact with entities like Store an Invoice, you need to initialize the SDK. This can be done in just one line of code:

```python
tonpay_sdk = Tonpay.create(TonNetwork.MAINNET, Sender())
```

Done! Now you can access everything that our SDK provides using the `tonpay_sdk` object.

{% hint style="info" %}
It's **highly recommended** to use Ton Connect 2.0 in the Sender as it's a network-wide standard.
{% endhint %}

### Short FAQ

You may be wondering - "what is sender?". The answer is simple - sender is an entity that is responsible for sending transactions to the TON Blockchain. You might want to use [TON Connect 2.0](https://docs.ton.org/develop/dapps/ton-connect/) for this, or implement a custom sender that uses your seed phrase to sign transactions and send them. Here's an example:

```python
from tonsdk.boc import Cell
from tonsdk.utils import Address, bytes_to_b64str
from tonsdk.contract.wallet import WalletVersionEnum, Wallets
from TonTools.Providers.TonCenterClient import TonCenterClient

from tonpay import Sender, get_http_endpoint

class MnemonicSender(Sender):

    def __init__(self, mnemonic: list): # list of words
        self.mnemonic = mnemonic

    async def send(self, value: int, address: Address, body: Cell, state_init: Cell = None):
        endpoint = await get_http_endpoint({'network': "mainnet", 'protocol': "rest"})
        client = TonCenterClient(base_url=endpoint)
        mnemonics, _pub_k, _priv_k, wallet = Wallets.from_mnemonics(self.mnemonic, WalletVersionEnum('v4r2'), 0)
        seqno = await client.get_wallet_seqno(wallet.address.to_string(True, True, True))
        query = wallet.create_transfer_message(
            address.to_string(True, True, True),
            value,
            seqno,
            body,
            state_init=state_init
        )
        boc = bytes_to_b64str(query["message"].to_boc(False))
        await client.send_boc(boc)

```


---

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

```
GET https://tonpay.gitbook.io/tonpay-sdk/python/initialization.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.
