function buyTx (buyer, issuerLsig, amount, algoAmount, appID, bondID) {
  return [
    // Algo transfer from buyer to issuer
    {
      type: types.TransactionType.TransferAlgo,
      sign: types.SignType.SecretKey,
      fromAccount: buyer,
      toAccountAddr: issuerLsig.address(),
      amountMicroAlgos: algoAmount,
      payFlags: { totalFee: 2000 }
    },
    // Bond token transfer from issuer's address
    {
      type: types.TransactionType.TransferAsset,
      sign: types.SignType.LogicSignature,
      fromAccountAddr: issuerLsig.address(),
      lsig: issuerLsig,
      toAccountAddr: buyer.addr,
      amount: amount,
      assetID: bondID,
      payFlags: { totalFee: 0 }
    },
    // call to bond-dapp
    {
      type: types.TransactionType.CallApp,
      sign: types.SignType.SecretKey,
      fromAccount: buyer,
      appID: appID,
      payFlags: { totalFee: 1000 },
      appArgs: ['str:buy']
    }
  ];
}
/**
 * Creates a group transaction for buying bond tokens.
 * @param buyer buyer account
 * @param issuerLsig Bond issuer logic signature
 * @param amount amount of bonds
 * @param algoAmount amount of Algo to pay for the bonds
 * @param appID Bond application index
 * @param bondID Bond ASA index
 */
Creates a group transaction for buying bond tokens.
Creates a group transaction for buying bond tokens .
function buyTx (buyer, issuerLsig, amount, algoAmount, appID, bondID) {
  return [
    {
      type: types.TransactionType.TransferAlgo,
      sign: types.SignType.SecretKey,
      fromAccount: buyer,
      toAccountAddr: issuerLsig.address(),
      amountMicroAlgos: algoAmount,
      payFlags: { totalFee: 2000 }
    },
    {
      type: types.TransactionType.TransferAsset,
      sign: types.SignType.LogicSignature,
      fromAccountAddr: issuerLsig.address(),
      lsig: issuerLsig,
      toAccountAddr: buyer.addr,
      amount: amount,
      assetID: bondID,
      payFlags: { totalFee: 0 }
    },
    {
      type: types.TransactionType.CallApp,
      sign: types.SignType.SecretKey,
      fromAccount: buyer,
      appID: appID,
      payFlags: { totalFee: 1000 },
      appArgs: ['str:buy']
    }
  ];
}
function buyTx ( buyer , issuerLsig , amount , algoAmount , appID , bondID ) { return [ { type : types . TransactionType . TransferAlgo , sign : types . SignType . SecretKey , fromAccount : buyer , toAccountAddr : issuerLsig . address ( ) , amountMicroAlgos : algoAmount , payFlags : { totalFee : 2000 } } , { type : types . TransactionType . TransferAsset , sign : types . SignType . LogicSignature , fromAccountAddr : issuerLsig . address ( ) , lsig : issuerLsig , toAccountAddr : buyer . addr , amount : amount , assetID : bondID , payFlags : { totalFee : 0 } } , { type : types . TransactionType . CallApp , sign : types . SignType . SecretKey , fromAccount : buyer , appID : appID , payFlags : { totalFee : 1000 } , appArgs : [ 'str:buy' ] } ] ; }
Creates a group transaction for buying bond tokens.
Creates a group transaction for buying bond tokens .
// Algo transfer from buyer to issuer // Bond token transfer from issuer's address // call to bond-dapp