question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simplified API for creating transactions

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
bartekncommented, Jan 15, 2019

If anyone’s interested in something similar: Stellar Burrito.

0reactions
morleyzhicommented, Feb 13, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found