Jump to content

terPRE_SEQ Missing/inapplicable prior transaction.


XRPLOVER1234
 Share

Recommended Posts

I get this error (terPRE_SEQ Missing/inapplicable prior transaction). What can i do to solve this 

const lib = require('xrpl-accountlib')
const { XrplClient } = require('xrpl-client')

const secret = 's----'
const account = 'a-----' // Can be derived

const client = new XrplClient('wss://s1.ripple.com')
const keypair = lib.derive.familySeed(secret)

const main = async () => {
  console.log('Getting ready...')
  const { account_data } = await client.send({ command: 'account_info', account })
    console.log(account_data.Sequence);
  const tx = {
    "TransactionType": "TrustSet",
    "Account": account,
    "Fee": "12",
    "Flags": 262144,
    "LastLedgerSequence": 8007750,
    "LimitAmount": {
      "currency": "TET",
      "issuer": "a----",
      "value": "100"
    },
    "Sequence": 68449162
}

  const {signedTransaction} = lib.sign(tx, keypair)
  const submit = await client.send({ command: 'submit', 'tx_blob': signedTransaction })
  console.log(submit.engine_result, submit.engine_result_message, submit.tx_json.hash)
  console.log(submit)
  client.close()
}

main()
Edited by XRPLOVER1234
Link to comment
Share on other sites

It is best that you don't manually input the sequences, I suggest requesting your respective node to provide you with your wallet's sequence and the ledger's last sequence.

When adding the ledger's last sequence, do this:

"LastLedgerSequence": (the given last ledger sequence)+ 30,

and please remember to refer to your node to provide you with these sequences.

Link to comment
Share on other sites

2 minutes ago, XRPLOVER1234 said:

@wojake Can you please come with a code example i dont understand it properly :) thanks 

I'm about to go to sleep, it's late, I'm sorry but maybe other js programmers could help you out.

Here's a simple explanation (read the docs):

1. connect to a xrpl node
2. request wallet's sequence
3. request ledger's sequence
4. use those provided information on the tx
5. make sure the ledger's last sequence is added by 30

Link to comment
Share on other sites

10 minutes ago, XRPLOVER1234 said:

@wojake 

Okay. Maybe you can help me tomorrow I will really appreciate it! :)

Because I still do not understand your answer and have been through all the docs.

And I really want to make a trustline.

If you want to set a Trustline, it is better if you use an already made application, I recommend using XUMM, which is made by XRPL Labs (funded by Ripple)

Link to comment
Share on other sites

I used this code. You can compare for the differences or missing pieces, or use the code as is. Also check the Flags, I remember to be kind of surprised to have to set them as below to get them "rippling disabled":

const xrpl = require('xrpl');

const SEED = 's..';
const ADDRESS = 'r..';

const CURRENCY = '534F4C4F00000000000000000000000000000000';
const ISSUER = 'rsoLo2S1kiGeCcn6hCUXVrCpGMWLrRrLZz';
const TRUST_AMOUNT = '1000000000';

async function main() {
  const client = new xrpl.Client('wss://s2.ripple.com')
  await client.connect();

  const wallet = xrpl.Wallet.fromSeed(SEED, { masterAddress: ADDRESS });
  const account_info = await client.request({
    command: 'account_info',
    account: ADDRESS,
    ledger_index: 'validated'
  })

  const ledger = await client.request({
    command: 'ledger_closed'
  })

  const currentLedger = ledger && ledger.result ? ledger.result.ledger_index : 0;
  const currentSequence = account_info && account_info.result ? account_info.result.account_data.Sequence : 0;

  if (currentLedger && currentSequence) {

    const tx = {
      TransactionType: 'TrustSet',
      Account: ADDRESS,
      Flags: 131072,
      LimitAmount: {
        currency: CURRENCY,
        issuer: ISSUER,
        value: TRUST_AMOUNT
      },
    }

    const prepared = await client.autofill(tx);
    console.log(prepared);
    if (parseFloat(prepared.Fee) > 600) {
      console.error('too high fee!!');
      process.exit(1);
    }
    const signed = await wallet.sign(prepared);

    const res = await client.submitAndWait(signed.tx_blob);
    console.log('result:', res);
  }

  // END
  client.disconnect();
}

main();

 

Edited by jn_r
Link to comment
Share on other sites

he is now able to create trustlines, but wants to issue his own token. The steps are:

1) set the default-ripple flag on the issuer account: https://xrpl.org/accountset.html#accountset-flags

2) send some amount of the asset from the issuer to an account that has a trustline opened to the issuer.

Link to comment
Share on other sites

I would appreciate some help from you @jn_r, I went through xrpl-py's documentation and their respective library but couldn't find a way to check an issued currency's supply.

Browsed xrpl.org as well and found nothing on my part.

If you could find a Request() method from xrpl.org, that would be beneficial as well, I just can't find a way to get this data.

Edited by wojake
Link to comment
Share on other sites

2 hours ago, wojake said:

I would appreciate some help from you @jn_r, I went through xrpl-py's documentation and their respective library but couldn't find a way to check an issued currency's supply.

Browsed xrpl.org as well and found nothing on my part.

If you could find a Request() method from xrpl.org, that would be beneficial as well, I just can't find a way to get this data.

Things seem to have changed a lot with the xrpl.js client update. I would use 'getBalances' in the previous javascript lib, but with the xrpl.js, it's all different. I think that you should use the request method() function described here: https://js.xrpl.org/interfaces/GatewayBalancesRequest.html

Edited by jn_r
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.