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-latest\weather-oracle\node_modules\conseiljs\dist\chain\tezos\TezosNodeWriter.js:398:19)
    at F:\oro-latest\weather-oracle\node_modules\conseiljs\dist\chain\tezos\TezosNodeWriter.js:150:13
    at Generator.next (<anonymous>)
    at fulfilled (F:\oro-latest\weather-oracle\node_modules\conseiljs\dist\chain\tezos\TezosNodeWriter.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

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, conseilServer.network, groupid, 5, networkBlockTime);

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.