flare_network_periphery

Typed Dart bindings for Flare Network's contracts, generated from Flare's own published ABI artifacts.

This is the companion to flare_network. The core package gives you a client, the contract registry, FTSOv2, the DA Layer, FDC and Smart Accounts. This package gives you everything else Flare publishes, as classes rather than hand-rolled ABIs.

import 'package:flare_network/flare_network.dart';
import 'package:flare_network_periphery/flare_network_periphery.dart';

final client = FlareClient(FlareChain.coston2);
final wnat = await IWNatContract.resolve(client);

// Read. Goes through eth_call, costs nothing, needs no account.
final supply = await wnat.totalSupply();

// Write. Returns an UNSIGNED request for your wallet to sign.
// This package holds no keys and never will.
final tx = wnat.depositTx(value: BigInt.from(10).pow(18), from: user);

What is in it

Counted from the generated source, not estimated:

Contract bindings 164
Read methods, callable through eth_call 1,049
Transaction builders, returning an unsigned request 513
Events, decodable from a log 592
Custom errors, decodable from a revert 168

Generated from @flarenetwork/flare-periphery-contract-artifacts. Every file carries the artifact version it came from in its header, so you can tell what a binding was built against without guessing.

Why this exists

Flare publishes developer guides for JavaScript, React, Python, Rust and Go, and none for Dart. Querying Flare's own documentation search for dart or flutter returns "No matching documents found".

A Flutter app could always reach Flare over JSON-RPC, and web3dart is a maintained general purpose Dart EVM library that works against any Flare RPC. That was never the gap. What did not exist is anything Flare specific: typed bindings for Flare's own contracts, so that FAssets, the asset manager, WNat and the rest are an import rather than a week of hand-rolled ABIs.

Two things worth knowing

Resolve, do not hardcode. Flare redeploys contracts, so every binding has a resolve constructor that goes through the contract registry. An address you pasted from a block explorer is a bug with a delay on it.

168 of Flare's custom errors carry no message. The node reports them as four opaque bytes and nothing else. Each binding can decode its own:

try {
  await client.prepareTransaction(tx);
} on FlareRpcException catch (e) {
  print(IAssetManagerContract.decodeRevert(e)?.description);
  // e.g. "InsufficientFundsForRedeem(1000000)"
}

Regenerating

The bindings are generated, and the generator is in the same repository:

dart run flare_network_codegen --artifacts <dir> --out <dir>

Do not edit files under lib/src/ by hand. They are overwritten.

Licence

See LICENSE.