Dart bindings for Trust Wallet Core, used in Flutter and Dart.
Package | Pub |
---|---|
wallet_core_bindings | |
wallet_core_bindings_native | |
wallet_core_bindings_wasm | |
wallet_core_bindings_libs | |
wallet_core_bindings_wasm_assets |
- TrustWalletCore include files and Protobuf file bindings.
- Provides Native and WebAssembly System Interface, supporting all platforms.
- APIs are repackaged for easier use.
- Combined with Dart GC, there is no need to control memory.
- Update the TrustWalletCore version synchronously and keep the APIs consistent.
There are two ways to use wallet_core_bindings, Native and Web Assembly. Please follow the instructions below to make your choice.
Platform | Native | Web Assembly | wallet_core_bindings_libs |
---|---|---|---|
Android | ✔️ | ✔️ | ✔️ |
iOS | ✔️ | ✔️ | ✔️ |
macOS | ✔️ | ✔️ | ✔️ |
Linux | ✔️ | ✔️ | ✔️ |
Windows | ❌️ | ✔️ | ❌️ |
Web | ❌️ | ✔️ | ❌️ |
The native features of the platform rely on the dynamic library compiled by Wallet Core, Binding with dart:ffi.
- wallet_core_bindings_libs contains native dynamic libraries. Windows is not supported at present.
- For more information, see wallet_core_bindings_libs.
dependencies:
wallet_core_bindings: version
wallet_core_bindings_native: version
wallet_core_bindings_libs: version
import 'package:wallet_core_bindings/wallet_core_bindings.dart';
import 'package:wallet_core_bindings_native/wallet_core_bindings_native.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await WalletCoreBindingsNativeImpl().initialize();
runApp(const MyApp());
}
Build WalletCore for WASM,Binding with WASI wasi_snapshot_preview1 and wasm_run.
- It is suitable for use on platforms that do not support native, such as Web and Windows. However, wasm itself has strong cross-platform features and is not limited to these two platforms.
dependencies:
wasm_run_flutter: version
wallet_core_bindings: version
wallet_core_bindings_wasm: version
wallet_core_bindings_wasm_assets: version
import 'package:wallet_core_bindings/wallet_core_bindings.dart';
import 'package:wallet_core_bindings_wasm/wallet_core_bindings_wasm.dart';
import 'package:wasm_run_flutter/wasm_run_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await WasmRunLibrary.setUp(override: false);
await WalletCoreBindingsWasmImpl().initialize();
runApp(const MyApp());
}
wallet_core_bindings provides the complete test cases, you can find usage here. See tests.
We need to extract the files from wallet-core and generate the corresponding Dart code so that Dart can communicate with TrustWalletCore.
Extract header files in include/TrustWalletCore and generate Dart bindings code.
cd wallet_core_bindings_native
dart run ffigen
Refer to the TrustWalletCore build documentation and complete the steps to generate files. Extract proto files in src/proto and use protoc_plugin to compile them into Dart code.
cd ./proto/TrustWalletCore/
protoc --dart_out=../../wallet_core_bindings/lib/proto/ ./*
If you want to use wallet_core_bindings in your commercial app, website or plugin, you need to obtain a commercial license from the author. Please contact [email protected] for more information.Once you obtain the license, your authorization information will appear in the AUTHORIZED.md.
GNU AGPLv3