Skip to content

Instantly share code, notes, and snippets.

@ChrisMarxDev
Last active June 19, 2020 08:20
Show Gist options
  • Save ChrisMarxDev/959770d5e43b717a70ce8ae7d829b328 to your computer and use it in GitHub Desktop.
Save ChrisMarxDev/959770d5e43b717a70ce8ae7d829b328 to your computer and use it in GitHub Desktop.
Function to load up a web3dart contract
// you will need the following import
// import 'package:flutter/services.dart';
Future<DeployedContract> loadContract() async {
String abiCode = await rootBundle.loadString("assets/abi.json");
String contractAddress = "0x8A30f78133176ed5E6CcB0AE8429AEEBf4c82Ffc";
final contract = DeployedContract(ContractAbi.fromJson(abiCode, "MetaCoin"),
EthereumAddress.fromHex(contractAddress));
return contract;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment