archethic_lib_dart 2.0.3 copy "archethic_lib_dart: ^2.0.3" to clipboard
archethic_lib_dart: ^2.0.3 copied to clipboard

Archethic dart library for Flutter for Node and Browser. This library aims to provide a easy way to create Archethic transaction and to send them over the network

example/example.dart

// ignore_for_file: unused_local_variable

import 'package:archethic_lib_dart/archethic_lib_dart.dart' show deriveKeyPair;
import 'package:archethic_lib_dart/src/model/transaction.dart';
import 'package:archethic_lib_dart/src/utils/utils.dart';

void main(List<String> args) {
  /// It creates a new keypair into hexadecimal format
  final keypair = deriveKeyPair('mysuperpassphraseorseed', 0);

  /// Generate `address`, `timestamp`, `previousPublicKey`, `previousSignature`, `originSignature` of the transaction and
  /// serialize it using a custom binary protocol.
  final transaction = Transaction(
          type: 'transfer', data: Transaction.initData(),)
      .addUCOTransfer(
          '00b1d3750edb9381c96b1a975a55b5b4e4fb37bfab104c10b0b6c9a00433ec4646',
          toBigInt(0.420),)
      .build('mysuperpassphraseorseed', 0, curve: 'P256')
    ..convertToJSON();

  /// Sign the transaction with an origin device private key
  final originKeypair = deriveKeyPair('origin_seed', 0);
  final transaction2 = Transaction(
          type: 'transfer', data: Transaction.initData(),)
      .addUCOTransfer(
          '00b1d3750edb9381c96b1a975a55b5b4e4fb37bfab104c10b0b6c9a00433ec4646',
          toBigInt(0.420),)
      .build('mysuperpassphraseorseed', 0, curve: 'P256')
      .originSign(originKeypair.privateKey)
    ..convertToJSON();

  /// Export the transaction generated into JSON
  final transaction3 = Transaction(
          type: 'transfer', data: Transaction.initData(),)
      .addUCOTransfer(
          '00b1d3750edb9381c96b1a975a55b5b4e4fb37bfab104c10b0b6c9a00433ec4646',
          toBigInt(0.420),)
      .build('mysuperpassphraseorseed', 0, curve: 'P256')
    ..convertToJSON();
}
5
likes
110
pub points
66%
popularity

Publisher

verified publisherarchethic.net

Archethic dart library for Flutter for Node and Browser. This library aims to provide a easy way to create Archethic transaction and to send them over the network

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

AGPL-3.0 (LICENSE)

Dependencies

crypto, crypto_keys, ecdsa, elliptic, freezed_annotation, gql, graphql, hex, http, json_annotation, jwk, pinenacl, pointycastle, secp256k1, x25519

More

Packages that depend on archethic_lib_dart