1

In most blockchains, it's possible to chain several outgoing transactions for an account. In Tezos we've tried to do the same, but got errors like:

Netezos.Rpc.InternalErrorException: [{"kind":"temporary","id":"proto.008-PtEdo2Zk.contract.counter_in_the_future","contract":"tz1Ywh6HfQoXnjeoN1GduTydLY73oj9DAgFw","expected":"958117","found":"958118"}]

It looks like the node is not able to chain several transactions depends on each other in the mempool.

Do we do something wrong or it's normal behaviour of the node? What are the best practices to do this?

1

The best way to send multiple transactions from a single account is grouping them into a single operation. Note that only manager operations (transaction, delegation, origination, reveal) can be grouped into a batch.

Here is an example (see more in Netezos docs):

var counter = await rpc.Blocks.Head
    .Context.Contracts[address].Counter.GetAsync<int>();

var opGroup = new ManagerOperationContent[]
{
    new TransactionContent // tx 1
    {
        Source = address,
        Counter = ++counter,
        ...
    },
    new TransactionContent // tx 2
    {
        Source = address,
        Counter = ++counter,
        ...
    },
    ...                    // etc
};

var bytes = await new LocalForge().ForgeOperationGroupAsync(branch, opGroup);
...
7
  • Yeah, thank you, this is clear. But in this case, I have to monitor if the previous batch included in the block or not. It would be awesome to have transactions chaining functionality in the node mempool as other blockchain nodes have. – Konstantin Ryazantsev May 25 at 8:08
  • @KonstantinRyazantsev you can do it actually. Here is an example: dotnetfiddle.net/WOTxoX – Groxan May 25 at 10:44
  • 1
    thank you. Your example works well and we've figured out why we have an error - before actually build a transaction we do the estimation via dry-run. And dry-run fails with an error if there is a transaction in the mempool – Konstantin Ryazantsev May 25 at 11:46
  • if there is a tx in the mempool and the next one is passed with counter+1 then the node responds with the counter_in_the_future. If there is a tx in the mempool and the next one is passed with counter then the node responds with Counter 958124 already used for contract – Konstantin Ryazantsev May 25 at 11:52
  • 1
    Done gitlab.com/tezos/tezos/-/issues/1405. Thank you @Groxan! – Konstantin Ryazantsev May 25 at 15:58

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.