Skip to content

Ton Provider

js
const provider = window.bitkeep.ton;
const provider = window.bitkeep.ton;

Support version

PlatformVersion
Chrome Extension>=v2.4.1
App(IOS)>= 8.10.0
App(Android)>= 8.10.0

ton_requestWallets

conncet to wallet.

js
const result = await provider.send('ton_requestWallets');

result = [{
    address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    publicKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    version: "v4R2"
}]
const result = await provider.send('ton_requestWallets');

result = [{
    address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    publicKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    version: "v4R2"
}]

ton_requestAccounts

get current address

js
const accounts = await provider.send('ton_requestAccounts');
const account = accounts[0];
const accounts = await provider.send('ton_requestAccounts');
const account = accounts[0];

accountsChanged

accounts changed event

js
provider.on('accountsChanged', function(accounts) {
    const account = accounts[0];

    console.log('accountsChanged', accounts);
});
provider.on('accountsChanged', function(accounts) {
    const account = accounts[0];

    console.log('accountsChanged', accounts);
});

ton_getChain

mainnet or testnet

js
provider.send("ton_getChain")
    .then(chainId => console.log({ chainId }))
    .catch((error) => {
        console.error(error);
    });
provider.send("ton_getChain")
    .then(chainId => console.log({ chainId }))
    .catch((error) => {
        console.error(error);
    });

wallet_switchChain

js
await provider.send("wallet_switchChain", "mainnet");

await provider.send("wallet_switchChain", "testnet");
await provider.send("wallet_switchChain", "mainnet");

await provider.send("wallet_switchChain", "testnet");

chainChanged

watch chain changed event

js
provider.on('chainChanged', (chainId) => {
 	//window.location.reload();
});
provider.on('chainChanged', (chainId) => {
 	//window.location.reload();
});

ton_getBalance

get balance of given address from current wallet

js
provider.send("ton_getBalance", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    .then(handleBalance)
    .catch((error) => {
        console.error(error);
    });
provider.send("ton_getBalance", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    .then(handleBalance)
    .catch((error) => {
        console.error(error);
    });

get balance of current address.

js
provider.send("ton_getBalance")
    .then(handleBalance)
    .catch((error) => {
        console.error(error);
    });
provider.send("ton_getBalance")
    .then(handleBalance)
    .catch((error) => {
        console.error(error);
    });

ton_rawSign

Returns a Promise that resolves with a string value, with is signatire for provided data.

js
const signature = await provider.send(
    'ton_rawSign',
    [{
        data: 'ABCDEF0123456789ABC56789ABCDEF0123456789'
    }]
);
const signature = await provider.send(
    'ton_rawSign',
    [{
        data: 'ABCDEF0123456789ABC56789ABCDEF0123456789'
    }]
);

ton_personalSign

Returns a Promise that resolves with a string value, with is signatire for hexed data.

js
const signature = await provider.send(
	"ton_personalSign", 
	{
	    data: "Hello world",
	}
);
const signature = await provider.send(
	"ton_personalSign", 
	{
	    data: "Hello world",
	}
);

ton_sendTransaction

js
const seqNo = provider.send(
	'ton_sendTransaction',
    [{
        to: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        value: '10000', // 10000 nanotons = 0.00001 TONs
        data: 'dapp for bitget',
        dataType: 'text'
    }]
);
const seqNo = provider.send(
	'ton_sendTransaction',
    [{
        to: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        value: '10000', // 10000 nanotons = 0.00001 TONs
        data: 'dapp for bitget',
        dataType: 'text'
    }]
);