How to use the stellar-sdk.Operation.payment function in stellar-sdk

To help you get started, we’ve selected a few stellar-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stellar-deprecated / stellar-sms-client / lib / commands / send-command.js View on Github external
.then(account => {
            console.log('Account loaded.');
            let asset = Asset.native();
            let amount = this._amount;
            let transaction = new TransactionBuilder(account)
              .addOperation(Operation.payment({
                destination: res.body.federation_json.destination_new_address,
                asset: asset,
                amount: amount
              }))
              .build();

            transaction.sign(keypair);

            stex.horizon.submitTransaction(transaction)
              .then(transactionResult => {
                console.log(transactionResult);
                stex.sms.sender.sendMessage(this._from, 'Transaction sent!');
              })
              .catch(e => {
                console.error(e);
                stex.sms.sender.sendMessage(this._from, 'Error sending transaction!');
github pakokrew / stellar-portal / app / js / helpers / StellarOperations.js View on Github external
export const sendPayment = ({ asset, destination, amount, memo }, authData) => {
  try {
    const operation = Operation.payment({
      destination,
      asset: AssetInstance(asset),
      amount: AmountInstance(amount),
    });
    return sendTransaction(authData, { operation, memo });
  } catch (e) {
    return Promise.reject(e);
  }
};
github satoshipay / solar / src / components / Withdrawal / Offramp.tsx View on Github external
const createWithdrawalTx = async (amount: BigNumber, asset: Asset, response: WithdrawalSuccessResponse) => {
    const memo = createMemo(response)
    const payment = Operation.payment({
      amount: amount.toString(),
      asset,
      destination: response.account_id
    })
    return createTransaction([payment], {
      accountData,
      horizon: props.horizon,
      memo,
      walletAccount: props.account
    })
  }
github satoshipay / solar / stories / TransactionReviewDialog.tsx View on Github external
const promise = (async () => {
      const account = await testnetHorizon.loadAccount("GBPBFWVBADSESGADWEGC7SGTHE3535FWK4BS6UW3WMHX26PHGIH5NF4W")
      return buildTransaction(
        account,
        [
          Operation.payment({
            amount: "20",
            asset: Asset.native(),
            destination: "GA2CZKBI2C55WHALSTNPG54FOQCLC6Y4EIATZEIJOXWQPSEGN4CWAXFT"
          })
        ],
        { memo: Memo.text("Demo transaction") }
      )
    })()
github satoshipay / solar / src / lib / transaction.ts View on Github external
export async function createPaymentOperation(options: PaymentOperationBlueprint) {
  const { amount, asset, destination, horizon } = options
  const destinationAccountExists = await accountExists(horizon, destination)

  if (!destinationAccountExists && !Asset.native().equals(options.asset)) {
    throw new Error(
      `Cannot pay in ${asset.code}, since the destination account does not exist yet. ` +
        `Account creations always need to be done via XLM.`
    )
  }

  const operation = destinationAccountExists
    ? Operation.payment({ destination, amount, asset })
    : Operation.createAccount({ destination, startingBalance: amount })

  return operation as xdr.Operation
}
github mobius-network / wallet / src / state / sagas / send / sendStartSaga.js View on Github external
function* buildTransaction({
  amount, asset, destination, memo,
}) {
  const account = yield select(getMasterAccount);
  const accountKeypair = yield select(getKeypairFor);

  const paymentOp = Operation.payment({
    destination,
    amount,
    asset: assets[asset],
  });

  let tx = new TransactionBuilder(account);

  if (memo) {
    tx = tx.addMemo(new Memo(MemoText, memo));
  }

  tx = tx.addOperation(paymentOp).build();

  tx.sign(accountKeypair);

  return tx;
github mobius-network / wallet / src / state / sagas / hackathonVote / sendHackathonVoteSaga.js View on Github external
function* run(args) {
  try {
    const { payload } = args;

    yield call(navigator.navigate, 'HackathonVote', 'Loading');

    const destination = HACKATHON_VOTING_ACCOUNT;

    const account = yield select(getMasterAccount);
    const keypair = yield select(getKeypairFor);

    const paymentOp = Operation.payment({
      destination,
      amount: '0.0000001',
      asset: assets.xlm,
    });

    let tx = new TransactionBuilder(account);

    const memoHash = createMemoHash(payload, keypair.publicKey());

    tx = tx.addMemo(Memo.hash(memoHash));
    tx = tx.addOperation(paymentOp).build();
    tx.sign(keypair);

    yield call(safeLoadAccount, destination);
    yield call(submitTransaction, tx);