call method

Future<int> call (BigInt address, MoacDefaultBlock block, { BigInt from, int gas, int gasPrice, int value, BigInt data })

Call Executes a new message call immediately without creating a transaction on the block chain. address: The address the transaction is sent to. from: (optional) The address the transaction is sent from. gas: (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions. gasPrice: (optional) Integer of the gasPrice used for each paid gas value: (optional) Integer of the value send with this transaction data: (optional) Hash of the method signature and encoded parameters. For details see Moac Contract ABI block: default block parameter Returns the return value of executed contract.

Implementation

Future<int> call(BigInt address, MoacDefaultBlock block,
    {BigInt from, int gas, int gasPrice, int value, BigInt data}) async {
  if (address == null) {
    throw ArgumentError.notNull("Moac::call - address");
  }
  if (block == null) {
    throw ArgumentError.notNull("Moac::call - block");
  }
  final String method = MoacRpcMethods.call;
  final String blockString = block.getSelection();
  Map<String, String> paramBlock = {
    "from": from == null ? null : MoacUtilities.bigIntegerToHex(from),
    "to": MoacUtilities.bigIntegerToHex(address),
    "gas": gas == null ? null : MoacUtilities.intToHex(gas),
    "gasPrice": gasPrice == null ? null : MoacUtilities.intToHex(gasPrice),
    "value": value == null ? null : MoacUtilities.intToHex(value),
    "data": data == null ? null : MoacUtilities.bigIntegerToHex(data)
  };
  paramBlock = MoacUtilities.removeNull(paramBlock);
  final dynamic params = [paramBlock, blockString];
  final res = await rpcClient.request(method, params);
  if (res != null && res.containsKey(moacResultKey)) {
    return MoacUtilities.hexToInt(res[moacResultKey]);
  }
  _processError(method, res);
  return null;
}