Calling contract invocation operation in loop

Tezos Asked by Pawan Dhanwani on December 4, 2020

I have some set of data which I am trying to push to my smart contract in loop. I use conseiljs to send data to smart contract.

Here is the code depicting what I am trying to do.

async function sendDataToContract(feedData,nodeAddress,publicKey,privateKey,keyHash,contractAddress) 
      const keystore = {
          publicKey: publicKey,
          privateKey: privateKey,
          publicKeyHash: keyHash,
          seed: '',
          storeType: conseiljs.StoreType.Fundraiser
      for(let i=0;i<feedData.length;i++)
            const result = await conseiljs.TezosNodeWriter.sendContractInvocationOperation(nodeAddress, keystore, contractAddress,  0, 100000, '', 1000, 750000, undefined, `(Pair "${feedData[i].firstname} ${feedData[i].income}")`, conseiljs.TezosParameterFormat.Michelson);
            console.log(" Catch Error : ",e.stack);

function sendData()

Catch Error:

Catch Error :  Error: (temporary: failure)
    at parseRPCError (F:oro-latestweather-oraclenode_modulesconseiljsdistchaintezosTezosNodeWriter.js:398:19)
    at F:oro-latestweather-oraclenode_modulesconseiljsdistchaintezosTezosNodeWriter.js:150:13
    at (<anonymous>)
    at fulfilled (F:oro-latestweather-oraclenode_modulesconseiljsdistchaintezosTezosNodeWriter.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

One Answer

I cover this in my Tezos workflows sample. The issue is that a blockchain operation is not recorded immediately. You need to wait for it be included before proceeding with the next one. Insider the try in the for loop, you need something like this:

const conseilResult = await TezosConseilClient.awaitOperationConfirmation(conseilServer,, groupid, 5, networkBlockTime);

Answered by Crypto Mike on December 4, 2020

Add your own answers!

Related Questions

About delegating XTZ

3  Asked on December 27, 2021 by nguyen-minh-dung


Why won’t tezos-client find my Ledger Nano S?

2  Asked on December 18, 2021 by tzduzit


How to calculate the total locked XTZ?

0  Asked on December 5, 2021 by innovativerp


How to send XTZ from fundraiser wallet

2  Asked on December 5, 2021 by nick-doulas


Question on receiving first staked reward

1  Asked on November 15, 2021 by clann


Why can’t I move my XTZ?

1  Asked on November 7, 2021 by user5185


Calling view of Fa1.2 contract

1  Asked on August 20, 2021


experience with AWS cloudHSM and remote-signer

0  Asked on August 20, 2021 by romain-braud


HTTP status codes for failing requests

0  Asked on August 20, 2021 by ivan-gromakovskii


Tezos GigaNode snapshots – Quick “latest” URL?

0  Asked on August 20, 2021 by babell


FA2 Permission Policies & Hook permission Behaviour

1  Asked on August 20, 2021 by vinnyson


Tezos.get_entrypoint_opt in Ligo issue

3  Asked on August 20, 2021 by anastasia-kondaurova


Trouble activating account on carthagenet

1  Asked on August 20, 2021 by lucasms


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir