alan 0.40.0+1 copy "alan: ^0.40.0+1" to clipboard
alan: ^0.40.0+1 copied to clipboard

outdated

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

example/example.dart

import 'package:alan/alan.dart';
import 'package:alan/proto/cosmos/bank/v1beta1/export.dart' as bank;

void main() async {
  // Create a wallet
  final networkInfo = NetworkInfo(
    bech32Hrp: 'did:com:',
    fullNodeHost: 'localhost',
  );

  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);

  // 3. Create and sign the transaction
  final message = bank.MsgSend.create()
    ..fromAddress = wallet.bech32Address
    ..toAddress = 'cosmos1cx7mec8x567xh8f4x7490ndx7xey8lnr9du2qy';
  message.amount.add(Coin.create()
    ..denom = 'uatom'
    ..amount = '100');

  final signer = TxSigner.fromNetworkInfo(networkInfo);
  final tx = await signer.createAndSign(wallet, [message]);

  // 4. Broadcast the transaction
  final txSender = TxSender.fromNetworkInfo(networkInfo);
  final response = await txSender.broadcastTx(tx);

  // Check the result
  if (response.isSuccessful) {
    print('Tx sent successfully. Response: ${response}');
  } else {
    print('Tx errored: ${response}');
  }
}
6
likes
0
pub points
57%
popularity

Publisher

unverified uploader

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, equatable, fixnum, grpc, hex, http, json_annotation, json_serializable, meta, pointycastle, protobuf

More

Packages that depend on alan