Skip to main content

Connect to Device

According to the workflow, you need to synchronize the hardware wallet data before initiating a transaction. This article introduces how to synchronize wallet data through the SDK.

tip

The private key will never be exported from the hardware wallet.

APIs​

MultiAccount​

The MultiAccount class is used to synchronize all currency information of the hardware wallet.

Map<String, dynamic> parseMultiAccounts(UR ur);

Parameters​

Input Parameter is a UR object, which is the output of URDecoder.

Returns​

  • device: the device model name.

  • masterFingerprint: the master fingerprint.

  • keys: the hdkey list.

  • deviceId: the device ID, such as serial numbers.

  • version: The versions.

  • nickName: the wallet account name.

Example​

import 'package:gs_ur_dart/gs_ur_dart.dart';

typedef SuccessCallback = void Function(UR);
final SuccessCallback onSuccess;

final QRViewController controller;

controller.scannedDataStream.listen((event) {
URDecoder urDecoder = URDecoder();
urDecoder.receivePart(event.code);
double progress = urDecoder.getProgress();
if (urDecoder.isComplete()) {
final UR result = urDecoder.resultUR();
if (!succeed) {
onSuccess(result);
succeed = true;
}
}
});

onSuccess(UR ur){
final account = parseMultiAccounts(ur);
}

If successfully synchronized, you can get wallet information similar to the following content:

{
"device": "GSWALLET",
"masterFingerprint": "27c3831f",
"keys": [
{
"chain": "BTC",
"path": "m/44'/0'/0'",
"publicKey":
"037fb66bad14245d08994f715480b276b73fd33e109f94f589021be6275984c861",
"name": null,
"xfp": "27c3831f",
"chainCode":
"529aa275a0e19c9d3e0fc82381927f9b63f8dbcc8332d1c36250db6ede23aba4",
"extendedPublicKey":
"xpub6CdezvjFXdc95pLVoAAfGEnS9MyVW1d763AMwDzDgr6aj6Fx67kzxmq3ugpSxYLHi6A8yNciYxTjg3sPy5UAJQptMwH2gBm4APtsrT3pd51",
"note": "{\"chain\":[\"Bitcoin\"]}"
},
{
"chain": "BTC",
"path": "m/86'/0'/0'",
"publicKey":
"033cdf0f1101dbf2e4a877b6b779aa59d345cb649c507cef76928e68c00789f83a",
"name": null,
"xfp": "27c3831f",
"chainCode":
"30884b52c8ed7c80eb42d967c62a3e26e5f5ea8c071f2a0bb3c47c7f4604de24",
"extendedPublicKey":
"xpub6DUp5pGy2P3emgQgoes1Qqmf2SmVB4c6tXAqcgDuKfXmNMv7kdnXmmFFcrNmaTbZiN4bNDcrEd6rHxkUE24J3Ehj14CVuGtJQhQhoccgAyZ",
"note": "{\"chain\":[\"Bitcoin\"]}"
},
{
"chain": "ETH",
"path": "m/44'/60'/0'",
"publicKey":
"0377d99c1b2762804f04263aeb470f9a89ece15cbc44977249e5c8e4843126dd27",
"name": null,
"xfp": "27c3831f",
"chainCode":
"b154fee3bf6210099ba1eab2c86fe525fc63abe1c8509abe88aa814574cc6e60",
"extendedPublicKey":
"xpub6DHPziqQ7we7dDW3MfEZN6GiTpj6mXM9SFdtu3gBvVUYm3D1LQHk6Cpf6DfBWojtwqPqHggXKqVqPacAV5R2MHqfJuECXZHFNxekjd4L31N",
"note":
"{\"chain\":[\"Ethereum\", \"BNB\", \"Polygon\", \"zkSync_Era\", \"Base\", \"Fantom\", \"Optimism\", \"Avalanche\", \"Arbitrum\"]}"
},

...

{
"chain": "KAS",
"path": "m/44'/111111'/0'",
"publicKey":
"02075aefa9ab67f17d9eb60854e2d6357859d4df67810315edc0573f61208063a9",
"name": null,
"xfp": "27c3831f",
"chainCode":
"bcb27cad4ccda2b6d0a450d76c65a5c1f8f518b4b531482a7dc9f66474b0ab5b",
"extendedPublicKey":
"xpub6CyUGvaHsKmHKSgyTssHgZUcdymuNxwcVY431h6psm1J57mftsgyhioCErvohw5fRLj5jnbNuQ9J4m6JZ7GkRCmZhS24SrcgTVxK1hAvdFe",
"note": "{\"chain\":[\"Kaspa\"]}"
}
],
"deviceId": "HQ01BI4217DE2973",
"version": "0.0.7",
"nickName": "baby"
}