Last active
September 6, 2021 19:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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