deploy method

Future<String> deploy(
  1. String privateKeyFrom
)

Implementation

Future<String> deploy(String privateKeyFrom) async {
  var creds = EthPrivateKey.fromHex(privateKeyFrom);
  var address = creds.address;
  var tx = Transaction(
      from: address,
      data: hexToBytes(_bytecode),
      gasPrice: EtherAmount.fromInt(EtherUnit.gwei, 20),
      maxGas: 474455);

  var res = await web3Client.sendTransaction(creds, tx, chainId: _chainId);
  if (res == '') {
    return '';
  }
  TransactionReceipt? receipt;
  try {
    receipt = await web3Client.getTransactionReceipt(res);
  } catch (e) {
    print('Transaction not in chain');
  }

  while (receipt == null) {
    sleep(Duration(seconds: 1));
    try {
      receipt = await web3Client.getTransactionReceipt(res);
    } catch (e) {
      print('Transaction not in chain');
    }
  }

  _contract = DeployedContract(
      ContractAbi.fromJson(_abi, 'RevocationRegistry'),
      receipt.contractAddress!);
  return receipt.contractAddress!.hexEip55;
}