Last active
June 17, 2020 13:54
-
-
Save ChrisMarxDev/712d1aa4264cdaf73ff16f4b84ba1e5a to your computer and use it in GitHub Desktop.
Query data & submit a transaction with web3dart
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> submit(String functionName, List<dynamic> args) async { | |
EthPrivateKey credentials = EthPrivateKey.fromHex( | |
"3d272d3193203d7a4458ea2a38ace936075c776512fc27093597ca2c790602a9"); | |
DeployedContract contract = await loadContract(); | |
final ethFunction = contract.function(functionName); | |
var result = await ethClient.sendTransaction( | |
credentials, | |
Transaction.callContract( | |
contract: contract, | |
function: ethFunction, | |
parameters: args, | |
), | |
); | |
return result; | |
} | |
Future<List<dynamic>> query(String functionName, List<dynamic> args) async { | |
final contract = await loadContract(); | |
final ethFunction = contract.function(functionName); | |
final data = await ethClient.call( | |
contract: contract, function: ethFunction, params: args); | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment