moca_chains 1.5.21 copy "moca_chains: ^1.5.21" to clipboard
moca_chains: ^1.5.21 copied to clipboard

Chains package for Moca App. This library gives the developer common methods for interacting with chains.

example/moca_chains_example.dart

import 'package:moca_chains/moca_chains.dart';

String mnemonic = '';
void main() async {
  ChainFactory.initialize('maya');
  Chain outbound = ChainFactory.instance.build();
  String outboundHex = await outbound.initMnemonic(mnemonic);
  outbound.getKeysFromPrivateHex(outboundHex).address;

  ChainFactory.initialize('kujira');
  Chain inbound = ChainFactory.instance.build();
  String hex = await inbound.initMnemonic(mnemonic);
  final inboundAddress = inbound.getKeysFromPrivateHex(hex).address;
  print(inboundAddress);
}

void uniswap() async {
  ChainFactory.initialize('usdc');

  ERC20 chain = ChainFactory.instance.build();
  final privateHex = await chain.initMnemonic(mnemonic);
  final keys = chain.getKeysFromPrivateHex(privateHex);

  final swapper = await SwapFactory(SwapperType.uniswap, 'moca');
  final params = GetQuoteParams(
      fromAsset: SupportedChains.usdc,
      toAsset: SupportedChains.usdc,
      amount: double.parse((2 * 1e6).toString()),
      destination: keys.address,
      affiliateBasis: null,
      sender: keys.address);
  final SwapQuote quote = await swapper.quote(params);

  final paramsMake = MakeSwapParams(
      fromAsset: SupportedChains.usdc,
      toAsset: SupportedChains.arb,
      amount: (2 * 1e6),
      destination: keys.address,
      privateHex: privateHex,
      memo: null,
      inboundAddress: null);

  final SwapResponse res = await swapper.make(paramsMake);
  print(quote.amountOut);
  print(res.inboundTxHash);
}
2
likes
0
pub points
76%
popularity

Publisher

unverified uploader

Chains package for Moca App. This library gives the developer common methods for interacting with chains.

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

bech32, bitcoin_base, blake2b, blockchain_utils, convert, cosmos_sdk, cryptography, dart_jsonwebtoken, dio, flutter_bitcoin, flutter_rust_bridge, http, on_chain, pointycastle, tuple, uuid, web_socket_channel

More

Packages that depend on moca_chains