Skip to main content

Atom

This article describes the process of completing a Atom transaction through the SDK.

Support List

Support most COSMOS-series cryptocurrencies.

  • Atom
  • Kava
  • Sei

GsWalletCosmosSDK

The GsWalletCosmosSDK class mainly implements the following functions:

  • Construct COSMOS transactions.
  • Parse signature information.
class GsWalletCosmosSDK {

static UR generateSignRequest({
String? uuid,
required String signData,
required String path,
required String chain,
required String xfp,
String? origin,
int? fee,
})

static Map<String, dynamic> parseSignature(UR ur);

}

generateSignRequest

static UR generateSignRequest({
String? uuid,
required String signData,
required String path,
required String chain,
required String xfp,
String? origin,
int? fee,
})

Input parameters

  • uuid: String optional Representing the unique ID of a transaction

  • signData: String required Unsigned-transaction data, it's serialized hex for a COSMOS transaction

  • path: String required BIP32 derivation path for from-address of the transaction

  • xfp: String required MasterFingerprint, used as a unique wallet ID

  • chain: String required Chain name

  • origin: String optional Notes for transaction, usually source of the request

  • fee: int optional Transaction fee, minimum unit.

parseSignature

static Map<String, dynamic> parseSignature(UR ur);

Returns

  • uuid: Uint8List transaction ID.

  • signature: String signature of transaction.

  • origin: String usually "GsWallet".

Example

Construct transaction

import 'package:gs_ur_dart/gs_ur_dart.dart';

UR ur = GsWalletCosmosSDK.generateSignRequest(
uuid: "cf727aa0-8d24-11ef-90ac-6dae386eaee6",
signData:
"0aa1010a8f010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126f0a2d636f736d6f7331373074666d7a3463323375336177746637346b6535746e676b656d6a6d3561617236376c6d70122d636f736d6f7331373074666d7a3463323375336177746637346b6535746e676b656d6a6d3561617236376c6d701a0f0a057561746f6d1206393738383030120d687562205468652067686f737412670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030edaa670d688c4ab1c9a8272c88fe62ec15be8c08903c43929e7be666c44953612040a020801180112130a0d0a057561746f6d12043139333610efdc041a0b636f736d6f736875622d3420d7917d",
path: "m/44'/118'/0'/0/0",
xfp: "27c3831f",
chain: "Cosmos_Hub",
origin: null,
fee: 2000);

final UREncoder urEncoder = UREncoder(ur);
String _currentQR = urEncoder.nextPart();
emit(_AnimatedQRDataState(_currentQR));
timer = Timer.periodic(const Duration(milliseconds: 250), (_) {
_currentQR = urEncoder.nextPart();
emit(_AnimatedQRDataState(_currentQR));
});

Parse signature

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 atomSigned = GsWalletCosmosSDK.parseSignature(ur);
}

// atomSigned: {
// "uuid": [207,114,122,160,141,36,17,239,144,172,109,174,56,110,174,230],
// "signature":"e6de945a91c14458b6a21fff2f3035882379e1da281ae1894d81fa525ab7b0e015ae216c7fe528d669a5b303aa3a61e79f0b9f54b18aa2739dfd8fc6988c8f10",
// "origin":"GSWALLET",
// };