Erc1056 constructor

Erc1056(
  1. String rpcUrl, {
  2. dynamic networkNameOrId = 1,
  3. String contractName = 'EthereumDIDRegistry',
  4. String contractAddress = '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b',
})

Implementation

Erc1056(String rpcUrl,
    {dynamic networkNameOrId = 1,
    String contractName = 'EthereumDIDRegistry',
    String contractAddress = '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b'}) {
  this.contractAddress = EthereumAddress.fromHex(contractAddress);

  _utf8 = Utf8Codec(allowMalformed: true);

  _erc1056contract = DeployedContract(
      ContractAbi.fromJson(abi, contractName), this.contractAddress);

  web3Client = Web3Client(rpcUrl, Client());

  if (networkNameOrId.runtimeType == int) {
    chainId = networkNameOrId;
    if (_numbersToNames.containsKey(networkNameOrId)) {
      networkName = _numbersToNames[networkNameOrId]!;
    } else {
      networkName = bytesToHex(intToBytes(BigInt.from(networkNameOrId)));
    }
  } else if (networkNameOrId.runtimeType == String) {
    networkName = networkNameOrId;
    if (_namesToNumbers.containsKey(networkNameOrId)) {
      chainId = _namesToNumbers[networkNameOrId]!;
    } else {
      chainId = 1337;
    }
  } else {
    throw Exception('Unexpected Runtime-Type for networkNameOrId');
  }
}