Demos Network Specifications
  • Introduction
    • What is Demos Network
    • Demos Network Architecture
  • FAQ
  • Cookbook
    • Project setup
      • Run the project (MacOS)
      • Run the project (Windows)
        • WSL 2 Setup on Windows (10 and 11 only)
        • Issue Troubleshooting
      • Run the project (Ubuntu)
  • SDK
    • Getting Started
    • WebSDK
      • Authentication
        • FIDO2 Passkeys
          • Under the Hood: FIDO2 Passkeys
      • NodeCalls
      • Transactions
        • Creating a transaction
        • Signing a transaction
        • Broadcasting a transaction
      • L2PS SDK
        • The l2ps module
        • Interacting with the L2PS
        • L2PS Messaging System
      • Instant Messaging
        • What is the Instant Messaging Protocol?
        • Architecture Overview
        • Encryption
        • Quickstart
        • Message Types
        • API Reference
        • FAQ
    • Cross Chain
      • General layout of the XM SDKs
      • EVM
      • BTC
      • Solana
      • MultiversX (EGLD)
      • NEAR
      • IBC
      • TON
      • XRPL
      • The XMScript
      • Identities
    • Demoswork
    • Cookbook
      • Demoswork
        • Creating work steps
        • Conditional Operation
        • Base Operation
        • Signing and broadcasting
      • Transactions
        • Crosschain Transaction
        • Native Transactions
      • SWAP
        • Crosschain SWAP
    • Web2
      • Quick Start
      • DAHR API Reference
        • Types
      • Making Requests
      • Identities
        • Twitter
        • GitHub
    • API Reference
    • Bridges
      • Rubic Bridge Test
    • Post Quantum Cryptography
  • Backend
    • Internal Mechanisms
      • Network Time Synchronization
      • Cross Context Identities
    • Global Change Registry
      • GCR Structure
      • How is GCR Synced?
    • Consensus Mechanism
      • Unparalleled Scalability
      • Decentralization in PoR-BFT
      • Enhanced Security
      • Comparative Advantage
      • Addressing Potential Criticisms
      • Conclusion
    • Communications Stack
    • L2PS (Subnet) Framework
      • How are L2PS transactions handled?
    • Miscellaneous
      • Browsing the Postgres DB via psql
    • Bridges
      • Rubic Bridge
    • Developers Testbed
      • Setting up the environment
      • Setting up the repository
      • Installing dependencies
      • Node Configuration
      • Running the node
  • Frontend
    • Demos Providers Discovery Mechanism
Powered by GitBook
On this page
  • Setting up a wallet
  • Creating the SDK instance
  • Connecting your wallet
  • Getting your address
  • Creating a transaction
  • Creating multiple transactions
  • Signing Messages
  • Cleaning up
  • Hacking
  • Resources
  • API Reference
  1. SDK
  2. Cross Chain

TON

PreviousIBCNextXRPL

Last updated 3 months ago

The Open Network (TON) is a decentralized and open internet, created by the community using a technology designed by Telegram.

Setting up a wallet

Install the wallet extension in your browser and create your wallet. Then export your recovery phrase by going to Settings > Recovery Phrase. Enter your password and save your phrase.

Creating the SDK instance

You need a HTTP endpoint provider to access the TON network. We'll use the endpoint provided by for that.

Install the package in your project to get started.

yarn add @orbs-network/ton-access

Then create the SDK instance as follows:

import { TON } from "@kynesyslabs/demosdk/xm-websdk"
import { getHttpEndpoint } from "@orbs-network/ton-access"

// Get the rpc url
const endpoint = await getHttpEndpoint({
    network: "testnet",
})

const instance = await TON.create(endpoint)

Connecting your wallet

You can connect your wallet using a mnemonic as follows:

await instance.connectWallet("wall park wife ...")

Getting your address

You can get your wallet address as follows:

const address = instance.getAddress()

Creating a transaction

Now you can create a signed TON transfer transaction.

const tx = await instance.prepareTransfer(
    "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N",
    "1",
)

Creating multiple transactions

You can create multiple transfer transactions using the prepareTransfers method.

const transfers = [
    {
        address: "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N",
        amount: "1",
    },
    {
        address: "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N",
        amount: "1",
    },
]

const txs = await instance.prepareTransfers(transfers)

Signing Messages

const message = "Hello, world!"

// Signing
const signature = await instance.signMessage(message)

// Verifying signature
const verified = await instance.verifyMessage(
    message,
    signature,
    instance.wallet.publicKey.toString("hex"),
)

expect(verified).toBe(true)

Cleaning up

You can remove your wallet and RPC connections as follows:

await instance.disconnect()

Hacking

You can access the underlying TonJs objects to have more control over the transactions and interactions with the blockchain.

Here is a list of the objects you can access:

Property
Type
Description

instance.provider

Provides read-only access to blockchain data

instance.signer

Allows for signing and broadcasting transactions

instance.wallet

Manages the private key and signing operations

Resources

  1. Ton web JS client

API Reference

The tx will be a signed buffer that can be sent to a DEMOS node for broadcasting.

The DEMOS TON sdk is built on top of the library, and only provides a limited set of methods to interact with the TON blockchain.

Tonkeeper
Orbs.com
@orbs-network/ton-access
BOC
TonJs
Official TON Website
Official TON Docs
Official TON JS Client
Explore TON wallets
Tonviewer - TON Block explore
https://kynesyslabs.github.io/demosdk-api-ref/classes/xmwebsdk.TON.html
TonClient
KeyPair
WalletContractV4