lifi_api_dart 0.1.2 copy "lifi_api_dart: ^0.1.2" to clipboard
lifi_api_dart: ^0.1.2 copied to clipboard

A Future-based library to interact with the Li.Fi API, allowing easy swapping of tokens between blockchain networks with Dart.

example/example.dart

import 'package:lifi_api_dart/lifi_api_dart.dart';

void main() async {
  /// Set up the config
  Config config = Config(
    // Staging (ie.testnet) support is limited.
    environment: Constants.production,
    apiVersion: Constants.v1,
  );

  /// Initialize the main object
  Lifi lifi = Lifi(config);

  /// Get chains available on the service
  await lifi.getChains().then((r) => print(r.body));

  /// Get tokens available on specific chains
  await lifi.getTokens(chains: ['ETH', 'DAI']).then((r) => print(r.body));

  /// Get info of a particular token, on a specific chain
  await lifi.getToken(chain: 'ETH', token: 'DAI').then((r) => print(r.body));

  /// Get a quote for a token transfer
  ///
  /// The quote contains a Transaction that can be signed and sent
  /// to the network using a wallet provider. eg. Ethers
  GetQuoteParams getQuoteParams = GetQuoteParams(
    fromChain: 'ETH',
    toChain: 'ETH',
    fromToken: 'USDC',
    toToken: 'ETH',
    fromAddress: '0x27cE6d2ee1FFB855f5618f898E4BdA164c35573E',
    fromAmount: '1000000',
  );
  await lifi.getQuote(getQuoteParams).then((r) => print(r.body));

  /// Close the connection
  lifi.close();
}
2
likes
160
pub points
0%
popularity

Publisher

verified publisher0xdir.com

A Future-based library to interact with the Li.Fi API, allowing easy swapping of tokens between blockchain networks with Dart.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

http

More

Packages that depend on lifi_api_dart