addDelegate method

Future<void> addDelegate(
  1. String privateKeyFrom,
  2. String identityDid,
  3. String delegateType,
  4. String delegateDid, {
  5. int validity = 86400,
})

Implementation

Future<void> addDelegate(String privateKeyFrom, String identityDid,
    String delegateType, String delegateDid,
    {int validity = 86400}) async {
  if (validity <= 0) throw Exception('negative validity');
  if (!_matchesExpectedDid(identityDid)) {
    throw Exception(
        'Information about $identityDid do not belong to this network');
  }
  var addDelegateFunction = _erc1056contract.function('addDelegate');
  Transaction tx = Transaction.callContract(
      contract: _erc1056contract,
      function: addDelegateFunction,
      parameters: [
        _didToAddress(identityDid),
        _to32ByteUtf8(delegateType),
        _didToAddress(delegateDid),
        BigInt.from(validity)
      ]);

  await web3Client.sendTransaction(EthPrivateKey.fromHex(privateKeyFrom), tx,
      chainId: chainId);
}