emerald_api 0.1.0 copy "emerald_api: ^0.1.0" to clipboard
emerald_api: ^0.1.0 copied to clipboard

Emerald API client for Dart and Flutter — gRPC stubs and a thin channel wrapper.

example/emerald_api_example.dart

// Estimates a transaction fee on Ethereum mainnet against the production API.
// Set EMERALD_API_TOKEN in the environment to authenticate; without a token
// the call fails with UNAUTHENTICATED.

import 'dart:io';

import 'package:emerald_api/blockchain.dart';
import 'package:emerald_api/common.dart';
import 'package:emerald_api/emerald_api.dart';

Future<void> main() async {
  final api = EmeraldApi(token: Platform.environment['EMERALD_API_TOKEN']);
  try {
    final response = await api.blockchain().estimateFee(
      EstimateFeeRequest()
        ..chain = ChainRef.CHAIN_ETHEREUM
        ..mode = FeeEstimationMode.AVG_LAST
        ..blocks = 10,
    );
    print('Estimated fee: $response');
  } on GrpcError catch (e) {
    print('gRPC error: ${e.code} ${e.message}');
  } finally {
    await api.shutdown();
  }
}
0
likes
155
points
--
downloads

Documentation

API reference

Publisher

verified publisheremerald.cash

Weekly Downloads

Emerald API client for Dart and Flutter — gRPC stubs and a thin channel wrapper.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

fixnum, grpc, protobuf

More

Packages that depend on emerald_api