deployed method

Future<bool> deployed(
  1. EthereumAddress? address,
  2. {BlockNum atBlock = const BlockNum.current()}
)

Checks if a contract is deployed.

  • address: The address of the contract.
  • optional atBlock: The block number to check. defaults to the current block

Returns a Future indicating whether the contract is deployed or not.

Implementation

Future<bool> deployed(EthereumAddress? address,
    {BlockNum atBlock = const BlockNum.current()}) {
  if (address == null) {
    return Future.value(false);
  }
  final isDeployed = _provider
      .send<String>('eth_getCode', [address.hex, atBlock.toBlockParam()])
      .then(hexToBytes)
      .then((value) => value.isNotEmpty);
  return isDeployed;
}