Skip to main content

Alephium

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

Support List

Supports transactions for Alephium cryptocurrency.

  • Alephium

GsWalletAlphSDK

The GsWalletAlphSDK class mainly implements the following functions:

  • Construct Alephium transactions.
  • Parse signature information.
class GsWalletAlphSDK {

static UR generateSignRequest({
String? uuid,
required String hexData,
required GsplDataType dataType,
List<Map<String, dynamic>>? outputs,
required String path,
required String xfp,
String? origin,
})

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

}

generateSignRequest

static UR generateSignRequest({
String? uuid,
required String hexData,
required GsplDataType dataType,
List<Map<String, dynamic>>? outputs,
required String path,
required String xfp,
String? origin,
})

Input parameters

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

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

  • dataType: GsplDataType required Transaction type

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

  • outputs: Map optional Transaction output section, which includes the following optional attributes: path, amount, signature, signHashType, address.

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

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

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 = GsWalletAlphSDK.generateSignRequest(
uuid: "cf75aef0-8d24-11ef-90ac-6dae386eaee6",
hexData:
"00000080004e20c1174876e80001a883fcf30592c310ce05ec7021ca3514a830dd3b6b73641f34c977146ba73b66abc447120002f27628958e3daf580e8e4fe120e1ded5761ea6b035d865a540726de65f08555a02c378cad1e25d0000000624efe13e0e7a9522c289253619a07da7787681d9d76031d9374333202469f100000000000000000000c40a68372bfb836000000624efe13e0e7a9522c289253619a07da7787681d9d76031d9374333202469f100000000000000000000",
dataType: GsplDataType.transaction,
path: "m/44'/1234'/0'/0/0",
outputs: [
{
"address": "1Qz7am3MSYoiZuPhYBJfaSrC46HaHwnbt62ycFNbK9DA",
"amount": "0034000000000000000"
}
],
xfp: "27c3831f",
origin: "GsWallet");

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

// alphSigned: {
// "uuid": [207,117,174,240,141,36,17,239,144,172,109,174,56,110,174,230],
// "signature":[228,162,92,69,221,37,94,111,94,162,91,89,128,41,159,51,52,93,63,117,181,179,83,149,157,24,57,0,97,15,225,31,81,96,201,114,209,77,77,30,210,58,86,13,143,81,222,221,189,140,242,139,88,105,190,118,150,27,41,156,30,56,63,133],
// "origin":"GSWALLET",
// };