getContractName method

String? getContractName()

Get the smart contract Name or null

Implementation

String? getContractName() {
  //old style json
  if (contractMeta["contractName"] != null) {
    return contractMeta['contractName'];
  }

  //new style json

  if (contractMeta['metadata'] != null) {}
  var m = json.decode(contractMeta["metadata"]);

  if (m['settings'] != null && m['settings']['compilationTarget'] != null) {
    List keys = m["settings"]["compilationTarget"].keys.toList();

    return m["settings"]["compilationTarget"][keys[0]];
  }

  //if there is no name return null
  return null;
}