0

Im building a bot that connects Stellar with Telegram but when I generate a new set of key pairs them don't match when I sign in stellarterm.

Here is the code:

var StellarSdk = require('stellar-sdk');

// Stellar

function Wallet(){
  var pair = StellarSdk.Keypair.random();
  return{
    secret: pair.secret(),

    public: pair.publicKey()
  }
}

I'm trying to access like this:

Wallet().secret 
Wallet().public

But it returns me wrong set of pair keys. Any idea why it is happening and how can I fix it?

1 Answer 1

3

Each time your call the Wallet function it generates a new keypair. You should save the invocation result into a variable:

var keypair = Wallet()
console.log(keypair1.secret, keypair2.public)
var anotherKeypair = Wallet()
2
  • Thank you Orbit I see it returns now the correct set of keys but just one time. Do you know a way it can returns different key set each time I call the function?
    – Natoshi
    Commented Sep 9, 2018 at 16:34
  • 3
    My friend, you should really start from learning the fundamentals. You won't be able to create anything adequate without basics. There are a lot of interactive JavaScript tutorials out there: codecademy, javascript.info. Also check modern es6 standard features and learn the basics of NodeJS. You will find answers for most of your questions there.
    – Orbit Lens
    Commented Sep 9, 2018 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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