getCode method
Get code, the code at the given address.
Implementation
Future<int?> getCode(
EthereumAddress? address, EthereumDefaultBlock? block) async {
if (address == null) {
throw ArgumentError.notNull('Ethereum::getCode - address');
}
if (block == null) {
throw ArgumentError.notNull('Ethereum::getCode - block');
}
const method = EthereumRpcMethods.code;
final blockString = block.getSelection();
final params = <String?>[address.asString, blockString];
final dynamic res = await _client.rpcClient.request(method, params);
if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
return EthereumUtilities.hexToInt(res[EthereumConstants.ethResultKey]);
}
_client.processError(method, res);
return null;
}