It is Dart packege that provide binding to TON SDK Client library. TON SDK (TONOS Client Library) is a library written in Rust that can be dynamically linked. It provides all heavy-computation components and functions, such as TON Virtual Machine, TON Transaction Executor, ABI-related functions, boc-related functions, crypto functions.
Add this to your package's pubspec.yaml file:
dependencies:
ton_client_dart: ^0.1.2
You can install packages from the command line:
$ pub get
Alternatively, your editor might support pub get. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:ton_client_dart/ton_client_dart.dart'
import 'package:ton_client_dart/ton_client_dart.dart'
//..
var CLIENT_DEFAULT_SETUP = {
'network': {
'server_address': 'http://localhost',
'message_retries_count': 5,
'message_processing_timeout': 40000,
'wait_for_timeout': 40000,
'out_of_sync_threshold': 15000,
'access_key': ''
},
'crypto': {'fish_param': ''},
'abi': {
'message_expiration_timeout': 40000,
'message_expiration_timeout_grow_factor': 1.5
}
};
//..
var client = TonClient();
await client.connect(CLIENT_SETUP);
//..
await client.disconnect();
To initialize the client, you need to call the TonClient.connect
function and pass the settings to it. After you have finished working with the client, you must close it with the TonClient.disconnect
function. Don't forget to call this functions.
await client.connect(CLIENT_DEFAULT_SETUP);
//..
var result = await client.version();
print(result.version);
//..
await client.disconnect();
//..
var query = await client.net.query_collection(ParamsOfQueryCollection(
collection: 'accounts',
result: 'id code',
filter: {
'id': {'eq': enmsg.address}
}));
//..
//..
var pq = ParamsOfQueryCollection(
collection: 'accounts',
result: 'id balance',
limit: 3,
order: [OrderBy(path: 'balance', direction: SortDirection.DESC())]
);
//..
//..
final code = await File('./test/files/run_get_code.txt').readAsString();
final data = await File('./test/files/run_get_data.txt').readAsString();
final res = await client.abi.encode_account(ParamsOfEncodeAccount(
state_init: StateInitSource_StateInit(code: code, data: data)));
final adr = await client.utils.convert_address(ParamsOfConvertAddress(
address: res.id, output_format: AddressStringFormat_Hex()));
var res_run_get = await client.tvm.run_get(ParamsOfRunGet(
account: res.account, function_name: 'participant_list'));
String result = res_run_get.output.toString();
//..
Note: see tests for more examples.
Note: you can see the contract deployment procces here.
- Linux - supported ✔️
- Windows - supported ✔️
- Android - supported ✔️ here
- iOS - supported ✔️ here
- macOS support will be implemented in future or on user demand.
- Web support will be implemented in future or on user demand.
- improve tests
- improve debot tests
- improve help documents and comments
- check memory leaks
- improve error msgs
- think about
- helper function usage
- query module
- contract auto deploy and runing module
- connect functoin with object from map param
cargo ndk --platform 21 --target x86_64-linux-android build --release