This Python script generates wallet information and a connection proof required for connecting wallets with Ton Connect.
README for Node.js available here
- Generates a TON wallet if no existing mnemonic is provided.
- Produces a proof object to validate wallet ownership for Ton Connect.
- Automatically handles manifest data and payloads.
-
Clone the repository or copy the script.
-
Ensure Python 3.10 is installed on your system.
-
Install the required dependencies:
pip install -r requirements.txt
Import the proof
function from the generator
module and call it:
from generator import proof
result = await proof(manifest_url="<manifest.url>", payload="<payload>", mnemonic="<mnemonic (optional)>")
<manifest.url>
: URL from the Ton Connect manifest, which specifies the app's identity and metadata.<payload>
: Optional payload data. UseNone
if no payload is required. IfNone
is passed, the payload is excluded from the generated proof.<mnemonic (optional)>
: An optional mnemonic (24 words) for an existing wallet. If omitted, a new wallet will be created.
A manifest contains metadata about the app. For example:
{
"url": "https://example.com",
"name": "Example App",
"iconUrl": "https://example.com/logo.png"
}
In this case, use example.com
as the <manifest.url>
parameter.
-
Create a new wallet and generate proof (with no payload):
from generator import proof result = await proof("example.com", None) print(result)
-
Use an existing wallet (with a provided payload):
from generator import proof result = await proof("example.com", "your-payload", "word1 word2 word3 ... word24") print(result)
The function generates a JSON object with wallet information and a connection proof. Example:
{
"wallet": {
"mnemonics": "word1 word2 word3 ... word24",
"ton_address": "UQ...8OtxN"
},
"address": "0:abcdef123...377c3a",
"network": "-239",
"public_key": "627c551...dcb67",
"private_key": "dbcb5077605...adbf85e641747bf",
"proof": {
"name": "ton_proof",
"timestamp": 1690000000,
"domain": {
"lengthBytes": 11,
"value": "example.com"
},
"signature": "fJqmtpUWO...sGhiYjubDg==",
"payload": "your-payload",
"state_init": "te6cckE...AGVgg=="
}
}
- wallet: Contains the mnemonic (seed phrase) and TON address in a readable format.
- address: Raw TON address with workchain info.
- network: The network ID (
-239
for mainnet and-1
for testnet). - proof:
- domain: The app domain extracted from the manifest.
- signature: Digital signature proving ownership of the wallet.
- state_init: Initialization data for the wallet.
Warning
This tool uses v4R2 wallet addresses.