transferVet method

Future<Map> transferVet(
  1. Wallet wallet,
  2. String to, {
  3. BigInt? value,
  4. Wallet? gasPayer,
})

Convenient function: do a pure VET transfer Parameters: to : Address of the receiver, value : optional Amount of VET to transfer in Wei, by default 0

Implementation

Future<Map> transferVet(Wallet wallet, String to,
    {BigInt? value, Wallet? gasPayer}) async {
  value ??= BigInt.zero;
  var clause = dev.Clause(to, value.toRadixString(10), '0x');
  RClause(to, value: value);
  var b = await getBlock();
  //TODO: emulate gas?
  var gas = 21000;
  var tx = buildTransaction(
      [clause], await getChainTag(), calcBlockRef(b["id"]), calcNonce(),
      gas: gas);

  Uint8List h = blake2b256([tx.encode()]);
  Uint8List sig = sign(h, wallet.priv).serialize();
  tx.signature = sig;
  String raw = '0x' + bytesToHex(tx.encode());
  return postTransaction(raw);
}