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.

transaction.sign is not a function

See original GitHub issue

Describe the bug I just upgraded to stellar javascript sdk 2.3.0. The old source code used to sign transactions using an instance of the TransactionBuilder’s sign() method. But now it doesn;t work, I get an error:

TypeError: transaction.sign is not a function

What version are you on? 2.3.0

To Reproduce Steps to reproduce the behavior:

  1. Create a transaction using the following
const transaction = await new StellarSdk.TransactionBuilder(sourceAccount,{
        timebounds: await StellarSdk.Server.fetchTimebounds(100),
        networkPassphrase: this.network,
        fee: (BASE_FEE == null ? 100 : BASE_FEE) * 1 
      }).addOperation(this.stellar.StellarSdk.Operation.payment({
          destination: recKeys.publicKey(),
          asset: SOME_ASSET, 
          amount: '' + amount.toFixed(7),
      }))

transaction.sign(senderKeys)
  1. The error happens on the last line transaction.sign(senderKeys)

Expected behavior For the transaction to be signed so i can submit to the stellar network

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
moda20commented, Nov 22, 2019

I figured out something which is to assign the transaction.build() to an other variable and use the new one since it is a Transaction object. let newTransaction = transaction.build() the way you mentioned doesn’t work for me.

1reaction
abuilescommented, Aug 19, 2019

@gate3 there are a couple of issues in your code:

  1. don’t use await in new StellarSdk.TransactionBuilder(sourceAccount,{
  2. You have to call .build() at the end of transaction builder - otherwise you end up calling sign on the wrong class.
  3. fetchTimebounds is not a static method on method, you should call it on a Server instance.

The following works:

  const transaction = new StellarSdk.TransactionBuilder(sourceAccount,{
    timebounds: await server.fetchTimebounds(100),
    networkPassphrase: StellarSdk.Networks.TESTNET,
    fee: 100,
  }).addOperation(StellarSdk.Operation.payment({
    destination: recKeys.publicKey(),
    asset: new StellarSdk.Asset.native(),
    amount: '100'
  })).build();


  transaction.sign(sendereKey);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Solana React TypeError: this.wallet.signTransaction is not a ...
signTransaction is not a function So I've logged about wallet and signTransaction is null. enter image description here.
Read more >
signTransaction is not a function? - Ethereum Stack Exchange
I want to test web3.js functionality, then I connect to Ganache, when I run the program web3.eth.getAccounts works properly, but web3.eth.
Read more >
typeerror: wallet.signtransaction is not a function - You.com
If you are getting a typeError that wallet.signTransaction is not a function, then it is likely that you have not imported the wallet...
Read more >
Using JavaScript API to interact with NEAR
To sign a transaction you'll need a KeyStore to create a connection. TestNet; MainNet; BetaNet; LocalNet. const { connect } ...
Read more >
web3.eth.accounts — web3.js 1.0.0 documentation
eth.accounts contains functions to generate Ethereum accounts and sign transactions and data. Note. This package has NOT been audited and might potentially be ......
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 Reddit Thread

No results found

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