alan 0.39.1 copy "alan: ^0.39.1" to clipboard
alan: ^0.39.1 copied to clipboard

outdated

Pure Dart library to easily integrate with any Cosmos-based chain.

example/example.dart

import 'package:alan/alan.dart';

void main() async {
  // -----------------------------------
  // --- Registering new msg types
  // -----------------------------------

  // MsgType needs to implement StdMsg
  // Codec.registerMsgType("my/MsgType", MyMsgType);

  // -----------------------------------
  // --- Creating a wallet
  // -----------------------------------

  final networkInfo = NetworkInfo(
    bech32Hrp: "did:com:",
    lcdUrl: "http://localhost:1317",
  );

  final mnemonicString =
      "vivid favorite regular curve check word bubble echo disorder cute parade neck rib evidence option glimpse couple force angry section dizzy puppy express cream";
  final mnemonic = mnemonicString.split(" ");
  final wallet = Wallet.derive(mnemonic, networkInfo);

  // -----------------------------------
  // --- Creating a transaction
  // -----------------------------------

  final message = MsgSend(
    fromAddress: wallet.bech32Address,
    toAddress: "did:com:1lys5uu683wrmupn4zguz7f2gqw45qae98pzn3d",
    amount: [StdCoin(denom: "uatom", amount: "100")],
  );

  final stdTx = TxBuilder.buildStdTx([message]);

  // -----------------------------------
  // --- Signing a transaction
  // -----------------------------------

  final signedStdTx = await TxSigner.signStdTx(stdTx, wallet);

  // -----------------------------------
  // --- Sending a transaction
  // -----------------------------------
  final result = await TxSender.broadcastStdTx(signedStdTx, wallet);

  // Check the result
  if (result.success) {
    print("Tx send successfully. Hash: ${result.hash}");
  } else {
    print("Tx send error: ${result.error.errorMessage}");
  }
}
6
likes
0
points
6
downloads

Publisher

unverified uploader

Weekly Downloads

Pure Dart library to easily integrate with any Cosmos-based chain.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, asn1lib, bip32, bip39, bip_bech32, bitcoin_flutter, equatable, hex, http, json_annotation, json_serializable, meta, pointycastle, reflectable

More

Packages that depend on alan