Skip to content

Instantly share code, notes, and snippets.

@s-a-y
Last active September 6, 2021 19:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-a-y/569e34b04828f540fc4aff3f9dadbe9d to your computer and use it in GitHub Desktop.
Save s-a-y/569e34b04828f540fc4aff3f9dadbe9d to your computer and use it in GitHub Desktop.
Difference from requestOperation method - you can add memo or time bounds to your transaction
const StellarSign = require('stellar-sign');
const StellarSdk = require('stellar-sdk');
StellarSdk.Network.usePublicNetwork();
const server = new StellarSdk.Server('https://horizon.stellar.org');
server.loadAccount('GBR3RS2Z277FER476OFHFXQJRKYSQX4Z7XNWO65AN3QPRUANUASANG3L')
.then(account => {
const builder = new StellarSdk.TransactionBuilder(account, {
memo: StellarSdk.Memo.text('test')
});
builder.addOperation(StellarSdk.Operation.createAccount({
destination: 'GCL245KQK5CLXMPO2JJTG36HBC4XWLGEZ5GZPKKWPE6CBOD3D2IDLOTO',
startingBalance: '2.01',
}));
StellarSign
.setHorizonUrl('https://horizon.stellar.org')
.useNetwork(StellarSdk.Networks.PUBLIC)
.requestTransaction(
StellarSdk.Keypair.fromSecret('...'),
'umbre1*papayame.com',
builder.build().toEnvelope().toXDR()
)
.then(tx => {
// transaction xdr with payment request sent to umbre1, if he accepts - transaction will be signed and submitted to the network.
console.log(tx);
})
.catch(err => {
console.error(err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment