Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/novusnota/tonutils-dart
Comprehensive Dart SDK for interacting with TON Blockchain. When combined with Flutter can be used for any popular platform out there!
https://github.com/novusnota/tonutils-dart
crypto cryptocurrency dart flutter hack-ton-berfest hacktoberfest library sdk the-open-network ton ton-blockchain
Last synced: 11 days ago
JSON representation
Comprehensive Dart SDK for interacting with TON Blockchain. When combined with Flutter can be used for any popular platform out there!
- Host: GitHub
- URL: https://github.com/novusnota/tonutils-dart
- Owner: novusnota
- License: apache-2.0
- Created: 2023-05-12T16:52:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-12T13:41:06.000Z (about 2 months ago)
- Last Synced: 2024-09-13T01:45:01.908Z (about 2 months ago)
- Topics: crypto, cryptocurrency, dart, flutter, hack-ton-berfest, hacktoberfest, library, sdk, the-open-network, ton, ton-blockchain
- Language: Dart
- Homepage: https://pub.dev/packages/tonutils
- Size: 274 KB
- Stars: 18
- Watchers: 1
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-ton - novusnota/tonutils-dart - Comprehensive Dart/Flutter SDK for TON Blockchain. (π§βπ» Get Coding / Libraries)
README
# π Dart/Flutter library for TON blockchain
A composable and versatile library for all things TON!
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![Pub](https://img.shields.io/pub/v/tonutils.svg)](https://pub.dartlang.org/packages/tonutils)WARNING: Some underlying APIs of this library are subject to change in near future, so it's advised to pin down specific minor version rather than specifying ranges in your pubspec.yaml. At least until we hit stable 1.0.0 release.
---
If you love this library and want to support its development you can donate any amount of coins to this TON address βΊοΈ`EQDew1rvHuMmMkmxG_fQahGymzIOF2_9TpgLftMUuxpKLE_u`\
To donate in other cryptocurrencies, use:## π° Features
- jsonRPC client to work with TON network: [lib/client](https://github.com/novusnota/tonutils-dart/blob/main/lib/client.dart)
- Cell, Slice, Builder, and BOC (de)serialization: [lib/dataformat](https://github.com/novusnota/tonutils-dart/blob/main/lib/dataformat.dart)
- Support for popular structures from block.tlb: [lib/dataformat](https://github.com/novusnota/tonutils-dart/blob/main/lib/dataformat.dart)
- Support of TON base64 addresses: [lib/dataformat](https://github.com/novusnota/tonutils-dart/blob/main/lib/dataformat.dart)
- Support of HashmapE: [lib/dataformat](https://github.com/novusnota/tonutils-dart/blob/main/lib/dataformat.dart)
- Support of TON & BIP39 Mnemonics: [lib/mnemonic](https://github.com/novusnota/tonutils-dart/blob/main/lib/mnemonic.dart)
- Support of wallets (v3, v3r2, v4r2): [lib/wallet](https://github.com/novusnota/tonutils-dart/blob/main/lib/wallet.dart)
- Ed25519 signing of transactions and crypto primitives: [lib/crypto](https://github.com/novusnota/tonutils-dart/blob/main/lib/crypto.dart)
- Workings with Jettons: [lib/jetton](https://github.com/novusnota/tonutils-dart/blob/main/lib/jetton.dart)
- Workings with NFTs: [lib/nft](https://github.com/novusnota/tonutils-dart/blob/main/lib/nft.dart)
- ...and much more!## π Usage
### Install via `dart pub`:
```bash
dart pub add tonutils
```### Get it all or use a few
Most common way is to import the whole library and cherry-pick the needed elements:
```dart
import 'package:tonutils/tonutils.dart' show Mnemonic;
```Alternatively, consider using only the sub-libraries if you know precisely what you need:
```dart
import 'package:tonutils/mnemonic.dart'; // provides Mnemonic and WordList classes
```**All the individual things you can import and use are listed in the [root of lib/ folder](https://github.com/novusnota/tonutils-dart/tree/main/lib).**
### RPC Client (Toncenter API)
You can use one of the public endpoints:
- Mainnet: https://toncenter.com/api/v2/jsonRPC
- Testnet: https://testnet.toncenter.com/api/v2/jsonRPCOr host [your own instance of TON HTTP API](https://github.com/toncenter/ton-http-api).
```dart
// Client uses testnet by default:
final testnetClient = TonJsonRpc();// But you can specify an alternative endpoint, say, for mainnet:
final client = TonJsonRpc('https://toncenter.com/api/v2/jsonRPC');// You can also specify an API key obtained from https://t.me/tonapibot!
// Generate a new key pair
var mnemonics = Mnemonic.generate();
var keyPair = Mnemonic.toKeyPair(mnemonics);// Wallet contracts use workchain = 0, but this can be overriden
var wallet = WalletContractV4R2.create(publicKey: keyPair.publicKey);// Opening a wallet contract (this specifies the TonJsonRpc as a ContractProvider)
var openedContract = client.open(wallet);// Get the balance of the contract
var balance = await openedContract.getBalance();
print(balance);// Create a transfer
var seqno = await openedContract.getSeqno();
var transfer = openedContract.createTransfer(
seqno: seqno,
privateKey: keyPair.privateKey,
messages: [
internal(
to: SiaString('EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N'),
value: SbiString('1.5'),
body: ScString('Hello, world!'),
)
],
);
print(transfer.toString());
```As you can see from this example, this library is 90% compatible with the API of the ton-core and ton-community TypeScript libraries. The main sources of divergence are types: this library uses sealed classes and extends from them to provide union-like types, while maintaining compile-time checked type safety and soundness.
But worry not β editor hints in VS Code, Emacs, Vim, NeoVim, Helix and other editors with Language Server Provider (LSP) support won't leave you astray and provide all the answers if you ever find yourself stuck.
### πΊ Videos
Playlist with examples on YouTube: [link](https://www.youtube.com/playlist?list=PLd8io4_DrUzlbG3SB89J1Eeq0VVdJh62R)
## π§ Tests
Tests are positioned to mirror the structure inside `lib/src/`, and grouped by the relative path from test folder to the test file (excluding the `_test.dart` suffix).
Examples:
- Tests for mnemonics are located in the file `test/mnemonic/mnemonic_test.dart`, and the test group name is `mnemonic/mnemonic`
- Tests for addresses are located in the file `test/dataformat/address/address_test.dart`, and the test group name is `dataformat/address/address`To invoke a group of tests by their name, run:
```bash
dart test -N 'group name'
```For example, to test mnemonics:
```bash
dart test -N 'mnemonic/mnemonic'
```## π License
Apache License 2.0