Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

toncenter/dapp-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ This is deprecated API, please use TON Connect

dapp-example

TON dApp example using TON Wallet Plugin.

Similar to new Metamask API

TON Wallet Plugin API is very similar to new Metamask API, based on eip-1193, eip-1102.

For simple migration we put two examples of dapps to this repository: TON dApp for TON Wallet Plugin (try), Ethereum dApp for Metamask (try).

API

TON Wallet Plugin injects in page window.ton object.

Plugin doesn't inject TonWeb library, but you can include it by yourself; In the future you will be able to use ton as provider: new TonWeb(window.ton)

Detecting TON Wallet Plugin

ton.isTonWallet

Requests to Plugin

ton.send(method: string, params?: Array<any>): Promise<any>; - The way to send requests to the plugin.

Currently there are 3 methods:

ton.send('ton_requestAccounts'): Promise<string[]> - get user wallet address.

ton.send('ton_sendTransaction', {value: string, to: string, data: string}) - send TON coins.

Where value - nanotons to send, to - destination address, data - additional data (comment)

ton.send('ton_getBalance'): Promise<string> - get user current wallet balance in nanotons.

See more in examples.

Plugin Events

ton.on(eventName: string, listener: (result: any) => void) - The way to add event listener to the plugin.

Currently there is 1 event:

ton.on('accountsChanged', listener: (accounts: Array<string>) => void) - emitted when user changed account.

Releases

No releases published

Packages

No packages published