stellar accounts code example

Example 1: stellar accounts

{
  "_links": {
    "self": {
      "href": "https://horizon.stellar.org/offers/165561423"
    },
    "offer_maker": {
      "href": "https://horizon.stellar.org/accounts/GCK4WSNF3F6ZNCMK6BU77ZCZ3NMF3JGU2U3ZAPKXYBKYYCJA72FDBY7K"
    }
  },
  "id": 165561423,
  "paging_token": "165561423",
  "seller": "GCK4WSNF3F6ZNCMK6BU77ZCZ3NMF3JGU2U3ZAPKXYBKYYCJA72FDBY7K",
  "selling": {
    "asset_type": "credit_alphanum4",
    "asset_code": "NGNT",
    "asset_issuer": "GAWODAROMJ33V5YDFY3NPYTHVYQG7MJXVJ2ND3AOGIHYRWINES6ACCPD"
  },
  "buying": {
    "asset_type": "native"
  },
  "amount": "18421.4486092",
  "price_r": {
    "n": 45112058,
    "d": 941460545
  },
  "price": "0.0479171",
  "last_modified_ledger": 28411995,
  "last_modified_time": "2020-02-26T19:29:16Z"
}

Example 2: stellar accounts

{
  "value": "MQ=="
}

Example 3: stellar accounts

{
  "type": "https://stellar.org/horizon-errors/transaction_malformed",
  "title": "Transaction Malformed",
  "status": 400,
  "detail": "Horizon could not decode the transaction envelope in this request. A transaction should be an XDR TransactionEnvelope struct encoded using base64.  The envelope read from this request is echoed in the `extras.envelope_xdr` field of this response for your convenience.",
  "extras": {
    "envelope_xdr": "BBBBBPORy3CoX6ox2ilbeiVjBA5WlpCSZRcjZ7VE9Wf4QVk7AAAAZAAAQz0AAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAA85HLcKhfqjHaKVt6JWMEDlaWkJJlFyNntUT1Z/hBWTsAAAAAAAAAAAL68IAAAAAAAAAAARN17BEAAABAA9Ad7OKc7y60NT/JuobaHOfmuq8KbZqcV6G/es94u9yT84fi0aI7tJsFMOyy8cZ4meY3Nn908OU+KfRWV40UCw=="
  }
}

Example 4: stellar accounts

var StellarSdk = require("stellar-sdk");
var server = new StellarSdk.Server("https://horizon.stellar.org");

var callback = function (resp) {
  console.log(resp);
};

var es = server
  .trades()
  .forAccount("GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K")
  .cursor("now")
  .stream({ onmessage: callback });

Example 5: stellar accounts

{
  "type": "https://stellar.org/horizon-errors/transaction_failed",
  "title": "Transaction Failed",
  "status": 400,
  "detail": "The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details.  Descriptions of each code can be found at: https://www.stellar.org/developers/guides/concepts/list-of-operations.html",
  "extras": {
    "envelope_xdr": "AAAAAgAAAADdfhHDs4Vaug6p8Oxb1QRjNRdJt3pYKKBVhFHrEgd9QAAAAAoAEi4YAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAESB31AAAAAQFhc/liVXbLk3NtB2BtweFJ064JdDIfrTSrqKMhb1oIRK+0PSyvjzZTkRCJmQY3bHNXYNuepa2TF7aBdibrb1gI=",
    "result_codes": {
      "transaction": "tx_insufficient_fee"
    },
    "result_xdr": "AAAAAAAAAAr////3AAAAAA=="
  }
}

Example 6: stellar accounts

{
  "_links": {
    "self": {
      "href": "https://horizon.stellar.org/accounts/GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K/trades?cursor=\u0026limit=3\u0026order=asc"
    },
    "next": {
      "href": "https://horizon.stellar.org/accounts/GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K/trades?cursor=107449584845914113-0\u0026limit=3\u0026order=asc"
    },
    "prev": {
      "href": "https://horizon.stellar.org/accounts/GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K/trades?cursor=107449468881756161-0\u0026limit=3\u0026order=desc"
    }
  },
  "_embedded": {
    "records": [
      {
        "_links": {
          "self": {
            "href": ""
          },
          "base": {
            "href": "https://horizon.stellar.org/accounts/GCO7OW5P2PP7WDN6YUDXUUOPAR4ZHJSDDCZTIAQRTRZHKQWV45WUPBWX"
          },
          "counter": {
            "href": "https://horizon.stellar.org/accounts/GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K"
          },
          "operation": {
            "href": "https://horizon.stellar.org/operations/107449468881756161"
          }
        },
        "id": "107449468881756161-0",
        "paging_token": "107449468881756161-0",
        "ledger_close_time": "2019-07-26T09:17:02Z",
        "offer_id": "104078276",
        "base_offer_id": "104078276",
        "base_account": "GCO7OW5P2PP7WDN6YUDXUUOPAR4ZHJSDDCZTIAQRTRZHKQWV45WUPBWX",
        "base_amount": "4433.2000000",
        "base_asset_type": "native",
        "counter_offer_id": "4719135487309144065",
        "counter_account": "GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K",
        "counter_amount": "443.3200000",
        "counter_asset_type": "credit_alphanum4",
        "counter_asset_code": "BB1",
        "counter_asset_issuer": "GD5J6HLF5666X4AZLTFTXLY46J5SW7EXRKBLEYPJP33S33MXZGV6CWFN",
        "base_is_seller": true,
        "price": {
          "n": 1,
          "d": 10
        }
      },
      {
        "_links": {
          "self": {
            "href": ""
          },
          "base": {
            "href": "https://horizon.stellar.org/accounts/GCQDOTIILRG634IRWAODTUS6H6Q7VUUNKZINBDJOXGJFR7YZ57FGYV7B"
          },
          "counter": {
            "href": "https://horizon.stellar.org/accounts/GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K"
          },
          "operation": {
            "href": "https://horizon.stellar.org/operations/107449486061649921"
          }
        },
        "id": "107449486061649921-0",
        "paging_token": "107449486061649921-0",
        "ledger_close_time": "2019-07-26T09:17:25Z",
        "offer_id": "104273938",
        "base_offer_id": "104273938",
        "base_account": "GCQDOTIILRG634IRWAODTUS6H6Q7VUUNKZINBDJOXGJFR7YZ57FGYV7B",
        "base_amount": "10.0000000",
        "base_asset_type": "native",
        "counter_offer_id": "4719135504489037825",
        "counter_account": "GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K",
        "counter_amount": "1.0000000",
        "counter_asset_type": "credit_alphanum4",
        "counter_asset_code": "BB1",
        "counter_asset_issuer": "GD5J6HLF5666X4AZLTFTXLY46J5SW7EXRKBLEYPJP33S33MXZGV6CWFN",
        "base_is_seller": true,
        "price": {
          "n": 1,
          "d": 10
        }
      },
      {
        "_links": {
          "self": {
            "href": ""
          },
          "base": {
            "href": "https://horizon.stellar.org/accounts/GAMU5TQFUMDGVKYQPPDCD2MKKUUWELSQAEKNNU4RFQCWFSRBPJA2MAGQ"
          },
          "counter": {
            "href": "https://horizon.stellar.org/accounts/GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K"
          },
          "operation": {
            "href": "https://horizon.stellar.org/operations/107449584845914113"
          }
        },
        "id": "107449584845914113-0",
        "paging_token": "107449584845914113-0",
        "ledger_close_time": "2019-07-26T09:19:30Z",
        "offer_id": "104299223",
        "base_offer_id": "104299223",
        "base_account": "GAMU5TQFUMDGVKYQPPDCD2MKKUUWELSQAEKNNU4RFQCWFSRBPJA2MAGQ",
        "base_amount": "748.5338945",
        "base_asset_type": "native",
        "counter_offer_id": "104299548",
        "counter_account": "GD3CJYUTZAY6JQF4CEI6Z7VW5O6VNGKZTBYUECTOJPEDTB7I2HZSPI2K",
        "counter_amount": "74.8533887",
        "counter_asset_type": "credit_alphanum4",
        "counter_asset_code": "BB1",
        "counter_asset_issuer": "GD5J6HLF5666X4AZLTFTXLY46J5SW7EXRKBLEYPJP33S33MXZGV6CWFN",
        "base_is_seller": true,
        "price": {
          "n": 10000000,
          "d": 100000001
        }
      }
    ]
  }
}

Example 7: stellar accounts

{
  "type": "https://stellar.org/horizon-errors/bad_request",
  "title": "Bad Request",
  "status": 400,
  "detail": "The request you sent was invalid in some way",
  "extras": {
    "invalid_field": "limit",
    "reason": "unparseable value"
  }
}

Example 8: stellar accounts

{
  "last_ledger": "28444678",
  "last_ledger_base_fee": "100",
  "ledger_capacity_usage": "0.2",
  "min_accepted_fee": "100",
  "mode_accepted_fee": "100",
  "p10_accepted_fee": "100",
  "p20_accepted_fee": "100",
  "p30_accepted_fee": "100",
  "p40_accepted_fee": "100",
  "p50_accepted_fee": "100",
  "p60_accepted_fee": "100",
  "p70_accepted_fee": "100",
  "p80_accepted_fee": "100",
  "p90_accepted_fee": "100",
  "p95_accepted_fee": "100",
  "p99_accepted_fee": "10000",
  "fee_charged": {
    "max": "100",
    "min": "100",
    "mode": "100",
    "p10": "100",
    "p20": "100",
    "p30": "100",
    "p40": "100",
    "p50": "100",
    "p60": "100",
    "p70": "100",
    "p80": "100",
    "p90": "100",
    "p95": "100",
    "p99": "100"
  },
  "max_fee": {
    "max": "16000",
    "min": "100",
    "mode": "100",
    "p10": "100",
    "p20": "100",
    "p30": "100",
    "p40": "100",
    "p50": "100",
    "p60": "100",
    "p70": "100",
    "p80": "100",
    "p90": "100",
    "p95": "100",
    "p99": "10000"
  }
}

Example 9: stellar accounts

var StellarSdk = require("stellar-sdk");
var server = new StellarSdk.Server("https://horizon.stellar.org");

var callback = function (resp) {
  console.log(resp);
};

var base = new StellarSdk.Asset.native();
var counter = new StellarSdk.Asset(
  "EURT",
  "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S",
);
var startTime = 1582156800000;
var endTime = 1582178400000;
var resolution = 3600000;
var offset = 0;

var es = server
  .tradeAggregation(base, counter, startTime, endTime, resolution, offset)
  .cursor("now")
  .stream({ onmessage: callback });

Example 10: stellar accounts

var StellarSdk = require("stellar-sdk");
var server = new StellarSdk.Server("https://horizon.stellar.org");

var callback = function (resp) {
  console.log(resp);
};

var es = server
  .strictSendPaths(
    new StellarSdk.Asset(
      "BRL",
      "GDVKY2GU2DRXWTBEYJJWSFXIGBZV6AZNBVVSUHEPZI54LIS6BA7DVVSP",
    ),
    "400",
    "GAYOLLLUIZE4DZMBB2ZBKGBUBZLIOYU6XFLW37GBP2VZD3ABNXCW4BVA",
  )
  .cursor("now")
  .stream({ onmessage: callback });

Tags:

Misc Example