Simplified API for creating transactions
See original GitHub issueI propose to add a simplified API for creating a single operation transactions. New methods will be added to Server
class and names representing operations that will be created:
var StellarSdk = require('stellar-sdk');
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
server.payment({
source: 'SCZZ5GHGUAY4OVME5G5FRQEF5XWBWMAIISB3GXPU24F3VHLMU75NAM4S',
destination: 'GC3FALN2RUQIYG2T4I5JIMSFQO6ZAVSRBC22E5TS3Q7Y7MUDIHM5X5M6',
amount: '10',
asset: StellarSdk.Asset.native()
}).then(result => {
console.log(result);
});
is equivalent of the following code built using current API:
var StellarSdk = require('stellar-sdk');
var keypair = StellarSdk.Keypair.fromSeed('SCZZ5GHGUAY4OVME5G5FRQEF5XWBWMAIISB3GXPU24F3VHLMU75NAM4S');
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
server.loadAccount(keypair.accountId())
.then(function(source) {
var transaction = new StellarSdk.TransactionBuilder(source)
.addOperation(StellarSdk.Operation.payment({
destination: 'GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD',
amount: "10",
asset: StellarSdk.Asset.native()
}))
.build();
transaction.sign(keypair);
server.submitTransaction(transaction)
.then(function(result) {
console.log(result);
});
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How Can I Use the Simplified Transaction Import Rest API?
This article is about the simplified transaction import REST API. ... Step 1 - Get your API key; Step 2 - Import transactions...
Read more >Introduction to the Real-Time Single Transaction API
The Real-Time Single Transaction API is a simple JSON-based REST Web Service that allows you to verify email addresses, phone numbers, and U.S....
Read more >Managing Transactions (REST Application Developer's Guide)
The REST Client API provides transaction control through the /transactions service and a txid parameter available on document manipulation and search requests.
Read more >Create Transactions | NEAR Documentation
To construct & process transactions you will need our API JavaScript ... we'll show you two ways to create a simple token transfer...
Read more >10+ Payment APIs to Make Transactions Easier - Nordic APIs
The Stripe API is one of the most popular payment APIs out there. It's easy to use and has many features, making it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If anyone’s interested in something similar: Stellar Burrito.
@bartekn I’m wary of adding API calls that do the same thing as existing calls, as we have to explain how they’re different (if at all), and that message might not come across. I think other packages like StellarBurrito (or alternate SDKs that we make) fill that need a lot better than the main SDK, which I think should focus on feature-completeness and backwards compatibility. So I’ll close this issue for now.
@Pedity-Luffy
new Server().loadAccount
doesn’t return an AccountCallBuilder instance:https://stellar.github.io/js-stellar-sdk/Server.html#loadAccount
You’re right that it’s a little confusing that some Server functions return CallBuilders and some don’t. I split that off into a separate issue:
https://github.com/stellar/js-stellar-sdk/issues/228
…but since that will be a breaking change that requires deprecating some endpoints, it might get deprioritized in favor of fixes that don’t break backwards compatibility.