3

In the below code, I explicitly gave the sequence number. How can I get the sequence number by giving the public key? Is there a way to get the sequence number of an account?

var StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
var an_account = new StellarSdk.Account("GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ", 46316927324160);
3

Try this:

var StellarSdk = require('stellar-sdk');
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org'); 
server.loadAccount("GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD")
  .then(function(account) { console.log(account.sequence) })

Returns:

33845557768224768

Also try:

server.loadAccount("GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD")
  .then(function(account) { console.log(account) })

Response looks like:

AccountResponse {
  _baseAccount:
   Account {
     _accountId: 'GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD',
     sequence: BigNumber { s: 1, e: 16, c: [Array] } },
  _links:
   { self:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD' },
     transactions:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD/transactions{?cursor,limit,order}',
        templated: true },
     operations:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD/operations{?cursor,limit,order}',
        templated: true },
     payments:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD/payments{?cursor,limit,order}',
        templated: true },
     effects:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD/effects{?cursor,limit,order}',
        templated: true },
     offers:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD/offers{?cursor,limit,order}',
        templated: true },
     trades:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD/trades{?cursor,limit,order}',
        templated: true },
     data:
      { href: 'https://horizon-testnet.stellar.org/accounts/GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD/data/{key}',
        templated: true } },
  id: 'GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD',
  paging_token: '',
  account_id: 'GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD',
  sequence: '33845557768224768',
  subentry_count: 0,
  thresholds: { low_threshold: 0, med_threshold: 0, high_threshold: 0 },
  flags: { auth_required: false, auth_revocable: false },
  balances: [ { balance: '10000.0000000', asset_type: 'native' } ],
  signers:
   [ { public_key: 'GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD',
       weight: 1,
       key: 'GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD',
       type: 'ed25519_public_key' } ],
  data: [Function],
  self: [Function],
  transactions: [Function],
  operations: [Function],
  payments: [Function],
  effects: [Function],
  offers: [Function],
  trades: [Function],
  data_attr: {} }
  • Hello @cesar. I am trying with snippet you provided but I am getting 'undefined' as an output. – merklexy Mar 13 '18 at 7:52
  • Oh sorry I made a type "seqeunce"... var server = new StellarSdk.Server('horizon-testnet.stellar.org'); server.loadAccount("GBFXHIQPYKUE7WPIACEVBIR3TRFKSYVO3LNGMQCZWNQQGRGPPGKOV7UD") .then(function(account) { console.log(account.sequence) }) – cesarm Mar 13 '18 at 7:54
  • var StellarSdk = require('stellar-sdk'); 'var server = new StellarSdk.Server('horizon-testnet.stellar.org'); server.loadAccount("GD2HPONSMOTEJQUE2WIUBPMWZ7WPAE7EBLW2RRD2XH6CIJHKCZKAYMZ3") .then(function(account) { console.log(account.seqeunce) })' Thorwing an error that cannot connect to insecure horizon server – merklexy Mar 13 '18 at 7:56
  • 1
    Perfect. It is working. Thanks a lot. Do you have any idea on multisig accounts? I am looking for that. If possible , any help – merklexy Mar 13 '18 at 8:23
  • 1
    @cesar...Could you check this link please. I posted the error also. 'stellar.stackexchange.com/questions/689/…' – merklexy Mar 13 '18 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.