moca_chains 1.3.6 copy "moca_chains: ^1.3.6" to clipboard
moca_chains: ^1.3.6 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';
import 'package:moca_chains/src/chains/evm/erc20.dart';
import 'package:moca_chains/src/swaps/swap_types.dart';

String mnemonic = '';
void main() async {
  final chain = ChainFactory('solana').build();
  final privateHex = await chain.initMnemonic('YOUR_MNEMONIC');
  final balance =
      await chain.getBalance(chain.getKeysFromPrivateHex(privateHex).address);
  print(balance);
}

void uniswap() async {
  ERC20 chain = ChainFactory('usdc').build();
  final privateHex = await chain.initMnemonic(mnemonic);
  final keys = chain.getKeysFromPrivateHex(privateHex);


  final swapper = await SwapFactory(SwapperType.uniswap);
  final params = GetQuoteParams(
        fromAsset: SupportedChains.usdc,
        toAsset: SupportedChains.arb,
        amount: double.parse((2 * 1e6).toString()),
        destination: keys.address,
        affiliateBasis: null,
        privateHex: privateHex);
  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);
}
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, dio, flutter_bitcoin, http, on_chain, pointycastle, uuid, web_socket_channel

More

Packages that depend on moca_chains