Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.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!');
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);
}
};
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
})
}
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") }
)
})()
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
}
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;
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);