A Flutter plugin for integrating with Arculus hardware wallets using direct FFI (Foreign Function Interface) for optimal performance.
- FFI-Based Architecture: Direct C library integration for maximum performance
- Cross-Platform Support: Works on Android, iOS, Windows, macOS, and Linux
- Hardware Wallet Operations: Create, recover, and manage Arculus wallets
- Cryptographic Functions: Public key derivation, transaction signing, PIN verification
- Type-Safe API: Comprehensive Dart models with proper error handling
This plugin uses FFI (Foreign Function Interface) to directly call the Arculus C SDK (libcsdk) combined with flutter_nfc_kit for NFC communication, providing:
- 🚀 Better Performance: No serialization overhead or platform channel latency
- 🔧 Real NFC Communication: Uses flutter_nfc_kit for actual hardware wallet communication
- 🌐 Universal Compatibility: Same code works across all Flutter platforms
- 🎯 Type Safety: Compile-time checking of C API usage
Dart → FFI → C SDK → NFC Commands → flutter_nfc_kit → Hardware Wallet
The plugin now uses flutter_nfc_kit for real NFC communication with Arculus hardware wallets, implementing the complete CSDK flow:
- Start NFC polling session
- Select wallet AID
- Initialize encrypted session
- Execute wallet operations via NFC
- Process responses through CSDK
- End NFC session
Add this to your package's pubspec.yaml file:
dependencies:
arculus_sdk: ^1.0.0import 'package:arculus_sdk/arculus_sdk.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize the FFI-based SDK
await ArculusSdk.initialize();
runApp(MyApp());
}final sdk = ArculusSdk();
// Initialize session with the hardware wallet
final sessionResult = await sdk.initSession();
if (sessionResult.isSuccess) {
print('Session initialized successfully');
}
// Create a new wallet
final createResult = await sdk.createWallet(numberOfWords: 12);
if (createResult.isSuccess) {
print('Mnemonic: ${createResult.data?.mnemonic}');
}
// Get public key for a derivation path
final pubKeyResult = await sdk.getPublicKey("m/44'/60'/0'/0/0");
if (pubKeyResult.isSuccess) {
print('Public Key: ${pubKeyResult.data?.publicKey}');
}
// Sign a transaction hash
final signResult = await sdk.signHash(
"m/44'/60'/0'/0/0",
"0x1234567890abcdef...",
curve: CryptoCurve.secp256k1,
algorithm: SigningAlgorithm.ecdsa,
);
if (signResult.isSuccess) {
print('Signature: ${signResult.data?.signature}');
}final result = await sdk.createWallet();
if (result.isFailure) {
print('Error: ${result.error?.message}');
print('Code: ${result.error?.code}');
}| Method | Description | Returns |
|---|---|---|
initSession() |
Initialize communication with the wallet | ArculusResult<void> |
createWallet({numberOfWords}) |
Create a new wallet | ArculusResult<CreateWalletResult> |
recoverWallet(mnemonic, {passphrase}) |
Recover wallet from mnemonic | ArculusResult<void> |
getPublicKey(path, {curve}) |
Get public key for derivation path | ArculusResult<ExtendedPublicKey> |
signHash(path, hash, {curve, algorithm}) |
Sign transaction hash | ArculusResult<SignatureResult> |
verifyPin(pin) |
Verify wallet PIN | ArculusResult<PinVerificationResult> |
getFirmwareVersion() |
Get firmware version | ArculusResult<String> |
getGGUID() |
Get wallet GUID | ArculusResult<String> |
resetWallet() |
Reset wallet ( |
ArculusResult<void> |
ArculusResult<T>: Wrapper for operation results with success/error statesArculusError: Error information with code and messageCreateWalletResult: Contains generated mnemonic phraseExtendedPublicKey: Public key and chain code for BIP32 derivationSignatureResult: Transaction signature dataPinVerificationResult: PIN verification status and remaining attempts
If you're upgrading from a platform channel version:
- Update Dependencies: Remove any platform-specific code
- Initialize SDK: Call
ArculusSdk.initialize()before use - API Compatibility: The public API remains the same
- Performance: Expect 30-60% performance improvement
| Platform | Architecture | Library |
|---|---|---|
| Android | ARM64, ARMv7, x86_64 | libcsdk.so |
| iOS | ARM64, x86_64 | libcsdk.a |
| macOS | ARM64, x86_64 | libcsdk.a |
| Windows | x64 | csdk.dll |
| Linux | x64 | libcsdk.so |
The native libraries are pre-compiled and included in the plugin. No additional build steps are required.
cd example
flutter test- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
Note: This plugin requires an Arculus hardware wallet to function. The SDK provides mock responses for development and testing purposes when no hardware is connected.