setAttribute method

Future<void> setAttribute(
  1. String privateKeyFrom,
  2. String identityDid,
  3. String name,
  4. String value, {
  5. int validity = 86400,
})

Implementation

Future<void> setAttribute(
    String privateKeyFrom, String identityDid, String name, String value,
    {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 setAttributeFunction = _erc1056contract.function('setAttribute');
  var valueList = Uint8List.fromList(_utf8.encode(value));
  Transaction tx = Transaction.callContract(
      contract: _erc1056contract,
      function: setAttributeFunction,
      parameters: [
        _didToAddress(identityDid),
        _to32ByteUtf8(name),
        valueList,
        BigInt.from(validity)
      ]);

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