Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(async (account) => {
let transaction = new StellarSdk.TransactionBuilder(account)
// Add a payment operation to the transaction
.addOperation(StellarSdk.Operation.createAccount({
destination: newPublicKey,
startingBalance: startingBalance, //At least 1 XLM to active new account
}))
// Uncomment to add a memo (https://www.stellar.org/developers/learn/concepts/transactions.html)
.addMemo(StellarSdk.Memo.text('Create a new account!'))
.build();
// Sign this transaction with the secret key
transaction.sign(srcKeyPair);
// Let's see the XDR (encoded in base64) of the transaction we just built
console.log(transaction.toEnvelope().toXDR('base64'));
// Submit the transaction to the Horizon server. The Horizon server will then
// submit the transaction into the network for us.
return await server.submitTransaction(transaction)
const makePayment = async (req, res) => {
const transaction = new Stellar.TransactionBuilder(accountA)
.addOperation(Stellar.Operation.payment({
destination: pairB.publicKey(),
asset: Stellar.Asset.native(),
amount: '30.0000001'
}))
.addOperation(Stellar.Operation.payment({
destination: pairB.publicKey(),
asset: Stellar.Asset.native(),
amount: '2.0005682'
}))
.build()
transaction.sign(pairA)
// Let's see the XDR (encoded in base64) of the transaction we just built
console.log("\nXDR format of transaction: ", transaction.toEnvelope().toXDR('base64'))
try {
const transactionResult = await server.submitTransaction(transaction)
console.log('\n\nSuccess! View the transaction at: ')
console.log(transactionResult._links.transaction.href)
.then(sourceAccount => {
var transaction = new StellarSdk.TransactionBuilder(sourceAccount)
.addOperation(StellarSdk.Operation.changeTrust(payload))
.build()
transaction.sign(sourceKeys)
server.submitTransaction(transaction)
.then( transactionResult => {
resolve({
payload: 'Success',
error: false
})
})
.catch( err => {
console.log('An error has occured:')
console.log(err)
reject({error: true, errorMessage: err})
})
})
})
.then(sourceAccount => {
var transaction = new StellarSdk.TransactionBuilder(sourceAccount)
.addOperation(StellarSdk.Operation.setOptions({ inflationDest: INFLATION_DESTINATION }))
.build()
transaction.sign(sourceKeys)
server.submitTransaction(transaction)
.then( transactionResult => {
resolve({ payload: transactionResult, error: false })
}).catch( err => {
console.log(err)
reject({ errorMessage: err, error: true })
})
})
})
.then(function(account) {
console.log("trusting the ncnt wallet");
var NCNT = new StellarSdk.Asset('NCNT', 'GBWOFUTXKI7IANMVHGBZX7KKK4LDDH7OVJ4C3WLX4V7M3WH2OKPBQEN5');
var transaction = new StellarSdk.TransactionBuilder(account)
.addOperation(StellarSdk.Operation.changeTrust({
destination: 'GB4IIY4IWZHCNPLCOY7IPYSZF6VUWGAVZ75JAPZSSUMYXPQQL44AB5L5',
asset: NCNT
}))
.build();
console.log('************************************************************');
console.log(wallet.canSign());
transaction.sign(wallet);
console.log("submitting trust transaction");
return server.submitTransaction(transaction);
})
.then(response => {
const runOperation = (from, type, options) => {
const operationBuilder = sdk.Operation[type]
if (!operationBuilder) {
return Promise.reject(new Error(`Unknown operation type: ${type}`))
}
return xlm.server.loadAccount(from.publicKey())
.then(sourceAccount => {
const operation = operationBuilder.call(sdk.Operation, options)
const tx = new sdk.TransactionBuilder(sourceAccount)
.addOperation(operation)
.build()
tx.sign(from)
return xlm.server.submitTransaction(tx)
})
}
export const sendPayment = ({ asset, keypair, sourceAccount, destination, amount }) => {
const sequenceNumber = sourceAccount.sequence;
const sourceAddress = keypair.accountId();
const transAccount = new Stellar.Account(sourceAddress, sequenceNumber);
const transaction = new Stellar.TransactionBuilder(transAccount)
.addOperation(Stellar.Operation.payment({
destination: destination,
asset: asset,
amount: amount
}))
.build();
transaction.sign(keypair);
return getServerInstance()
.submitTransaction(transaction);
};
.then(account => {
const tx = new StellarSdk.TransactionBuilder(account)
.addOperation(StellarSdk.Operation.createAccount({
destination: publicKey,
startingBalance: this.account.amount.toString()
}))
.setTimeout(0)
.build();
return {
tx: tx,
network: network
};
})
.then(this.Reviewer.review)
export const changeTrust = ({ asset, limit, keypair, sourceAccount }) => {
const sequenceNumber = sourceAccount.sequence;
const sourceAddress = keypair.accountId();
const transAccount = new Stellar.Account(sourceAddress, sequenceNumber);
const trustLimit = isString(limit) ? limit : undefined;
const transaction = new Stellar.TransactionBuilder(transAccount)
.addOperation(Stellar.Operation.changeTrust({
asset,
limit: trustLimit,
}))
.build();
transaction.sign(keypair);
return getServerInstance()
.submitTransaction(transaction);
};
.then(account => {
const tx = new StellarSdk.TransactionBuilder(account)
.addOperation(StellarSdk.Operation.setOptions({
inflationDest: destination
}))
.setTimeout(0)
.build();
return {
tx: tx,
network: this.account.network
};
})