Skip to content

Instantly share code, notes, and snippets.

@ChrisMarxDev
Last active June 17, 2020 13:56
Show Gist options
  • Save ChrisMarxDev/42e8ef116fc22ad2c02a2b5529f7ce5d to your computer and use it in GitHub Desktop.
Save ChrisMarxDev/42e8ef116fc22ad2c02a2b5529f7ce5d to your computer and use it in GitHub Desktop.
Smart contract related functions to call MetaCoin example
Future<String> sendCoind(String targetAddressHex, int amount) async {
EthereumAddress address = EthereumAddress.fromHex(targetAddressHex);
// uint in smart contract means BigInt for us
var bigAmount = BigInt.from(amount);
// sendCoin transaction
var response = await submit("sendCoin", [address, bigAmount]);
// hash of the transaction
return response;
}
Future<List<dynamic>> getBalance(String targetAddressHex) async {
EthereumAddress address = EthereumAddress.fromHex(targetAddressHex);
// getBalance transaction
List<dynamic> result = await query("getBalance", [address]);
// returns list of results, in this case a list with only the balance
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment