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++)
{
try
{
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(result.operationGroupID);
}
catch(e)
{
console.log(" Catch Error : ",e.stack);
}
}
}
function sendData()
{
sendDataToContract(feedData,nodeAddress,publicKey,privateKey,keyHash,contractAddress);
}
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 Generator.next (<anonymous>)
at fulfilled (F:oro-latestweather-oraclenode_modulesconseiljsdistchaintezosTezosNodeWriter.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);
Answered by Crypto Mike on December 4, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP