makeTransferTx method

Future<Transaction> makeTransferTx (String tokenType, Address from, Address to, BigInt amount, int gasPrice, int gasLimit, Address payer)

Implementation

Future<Transaction> makeTransferTx(String tokenType, Address from, Address to,
    BigInt amount, int gasPrice, int gasLimit, Address payer) async {
  amount = verifyAmount(amount);
  var struct = Struct();
  struct.list.addAll([from, to, amount]);

  var pb = VmParamsBuilder();
  pb.pushNativeCodeScript([
    [struct]
  ]);
  var params = pb.buf.bytes;

  var contract = await getTokenContractAddr(tokenType);
  var txb = TxBuilder();
  var tx = await txb.makeNativeContractTx('transfer', params, contract,
      gasPrice: gasPrice, gasLimit: gasLimit, payer: payer);

  tx.tokenType = tokenType;
  tx.from = from;
  tx.to = to;
  tx.amount = amount;
  tx.method = 'transfer';
  tx.payer = payer ?? from;
  return tx;
}