Skip to content

andreykobal/ton-connector-unity

Repository files navigation

TON UNITY SDK

ton-sdk

The TON UNITY SDK allows you to connect TON-compatible wallets in Unity using QR code and send transactions. This SDK uses Ton Connect v2 for wallet integration.

How to Use

Prerequisites

Before using this SDK, you need to have:

  • Unity 2018 or later installed.
  • A TON-compatible wallet.
  • Ton Connect v2.

Installation

  1. Clone the repository and add the TonConnect.cs script to your Unity project.
  2. Create an empty game object in your scene and attach the TonConnect.cs script to it.
  3. Attach RawImage components to the image1 and image2 variables in the TonConnect script.
  4. Attach the TransactionSender script to any game object that will send transactions.
  5. Attach the Button component to the sendTransactionButton variable in the TonConnect script.

Usage

  1. In the Start() method of the TonConnect script, create a ConnectRequest object with the manifestUrl and items properties.
  2. Serialize the ConnectRequest object to JSON.
  3. Generate a random ID using the GenerateRandomId() method.
  4. Generate the Ton Connect URL by appending the v, id, r, and ret parameters to the wallet universal URL.
  5. Load the QR code image using the LoadQrCode() method and pass in the Ton Connect URL and the RawImage component.
  6. Open a server-sent events stream using the OpenSSEStream() method and pass in the client ID.
  7. To send a transaction, simply click the sendTransactionButton. This will call the SendTransaction() method in the TransactionSender script, passing in the client ID.

Examples

See the included SampleScene in the Unity project for an example implementation.

Contributors

This project was created by @andreykobal. Feel free to contribute to this project by submitting pull requests or issues.

About

Simple Unity connector for TON protocol

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors