TonLib Node JS
TonLib Node JS implementation based on FFI-NAPI library.
Supported Operating Systems
- Ubuntu 18
- Windows x86_64
- Mac OS 10.15
Installation
yarn
yarn add @kibcode/tonlib-node
npm
npm i @kibcode/tonlib-node
Examples
Common usage
import {Client} from './src';
import {testInitConfig} from './test-init-config';
(async () => {
const client = new Client();
client.on(data => console.log('Hey, I got some data!', data));
client.send({'@type': 'setLogVerbosityLevel', 'new_verbosity_level': 1});
function getAddressInformation(timeout: number) {
return client
.request({
'@type': 'getAccountState',
account_address: {
'@type': 'accountAddress',
account_address: 'EQAogu1aTrj2GWzA3BsHGxadmOTheuRubH5GY54XSRFr497x'
}
}, {timeout})
.then(i => console.log('Address information:', i))
.catch(e => console.log('Error while getting address information:', e));
}
await getAddressInformation(10000);
await client.request(testInitConfig).then(r => console.log('Init result:', r));
await getAddressInformation(30000);
})();
Usage with types generator
import {Client} from './src';
import {TonLib} from '@ton.js/types';
const client = new Client();
client.send<TonLib.Combinators.SetLogVerbosityLevel>({
'@type': 'setLogVerbosityLevel',
new_verbosity_level: 1,
});