Last active
June 17, 2020 13:56
-
-
Save ChrisMarxDev/42e8ef116fc22ad2c02a2b5529f7ce5d to your computer and use it in GitHub Desktop.
Smart contract related functions to call MetaCoin example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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