Cardaon integration

Dear Experts, please help me too in my issue…

I am receiving following error while cardano integration on sandtest mode…

Shelley command failed: query utxo Error: A query from a certain era was applied to a ledger from a different era: EraMismatch {ledgerEraName = “Byron”, otherEraName = “Shelley”}

I am running this code…

CARDANO_CLI_PATH,
“query”, “utxo”,
“–testnet-magic”, CARDANO_NETWORK_MAGIC,
“–address”, walletAddress
].join(" "));
console.log(rawUtxoTable);
// Calculate total lovelace of the UTXO(s) inside the wallet address
const utxoTableRows = rawUtxoTable.data.trim().split(’\n’);
let totalLovelaceRecv = 0;
let isPaymentComplete = false;

for(let x = 2; x < utxoTableRows.length; x++) {
const cells = utxoTableRows.split(" ").filter(i => i);
total

LovelaceRecv += parseInt(cells[2]);
}

Also i set DB Socket variable
“export CARDANO_NODE_SOCKET_PATH=”/home/neerajlinux/relay/db/node.socket"

Please help!!! Thank you!!

Looks like the node has not finished syncing. Since it thinks it is still in an earlier era.

Also: Please don’t post the same question in lots of threads.

My apologies for posting same query in other threads…

Sir,

What is Node syn? Do we have to wait for 4 hours for sync to happen to make any test changes?

2
Is it related to Start “cardano-node run” command in Linux cmd and wait for Node sync?

Also, we are using this version…

“cardano-cli 1.25.1 - linux-x86_64 - ghc-8.10 cardano-node 1.25.1
git rev 9a7331cce5e8bc0ea9c6bfa1c28773f4c5a7000f”

Please suggest, thank you!!1

When the node is started, it has to download the blockchain from other nodes and update its own view of what the current status is. For mainnet, this takes something in the range of 24 hourse, for testnet, it might be less, but I don’t know.

If you, in the future, had the node offline for some time, it will also need to synchronise quite a lot of data. It will not take that much, but can be several minutes, depending on how long it was offline.

Yes, you have to start the node and let it run. Either in a separate terminal or as a service.

You can query if it is ready as, for example, described here:

(Although you don’t have to compare the slot number with the latest slot manually, anymore. Newer versions of cardano-cli will give you a percentage directly.)

That version is very old. Current version is 1.34.1. You should really start with a newer version.

thank you sir for your kind reply, it was all very helpful…

  1. We are currently running this on our local windows machine ( server ), if we need to run this code on live server, how should we run it? I mean we just put this JS file thats generated on LIVE server and it works automatically and gets connected to some CARDANO server?

CARDANO_CLI_PATH,
“query”, “utxo”,
“–testnet-magic”, CARDANO_NETWORK_MAGIC,
“–address”, walletAddress
].join(" "));
console.log(rawUtxoTable);
// Calculate total lovelace of the UTXO(s) inside the wallet address
const utxoTableRows = rawUtxoTable.data.trim().split(’\n’);
let totalLovelaceRecv = 0;
let isPaymentComplete = false;

for(let x = 2; x < utxoTableRows.length; x++) {
const cells = utxoTableRows.split(" ").filter(i => i);
totalLovelaceRecv += parseInt(cells[2]);
}

// Determine if the total lovelace received is more than or equal to
// the total expected lovelace and displaying the results.
isPaymentComplete = totalLovelaceRecv >= TOTAL_EXPECTED_LOVELACE;

And is there way for us to know that node has been synced successfully?

1 Like

You can run a node on a local machine or on a server.

Depends on what you want to do.

I cannot see, what your Javascript code is supposed to do. The beginning is missing. But it looks like it just checks if a certain amount of ADA is available on an address.

This snippet can only run on a machine, where cardano-node and cardano-cli are installed and cardano-node is running.

As described in the article I linked.

cardano-cli query tip --testnet-magic 1097911063 (for testnet) or cardano-cli query tip --mainnet will show you, how far the node is synced.

Actually, we used this code to receive payments…

(Taking javascript code)

Ah, okay. All of these examples just call cardano-cli and process its output.

They will need cardano-cli installed on the same machine. And cardano-cli will need a running and fully synched cardano-node also on the same machine.

Depending on what you want to do, APIs like blockfrost.io might be a better fit for your use case.

1 Like

yes sir, it gives error policy…

“[Neeraj-P:cardano.node.ErrorPolicy:Notice:50] [2022-03-24 18:34:02.49 UTC] IP 54.241.77.32:3001 ErrorPolicySuspendConsumer (Just (ConnectionExceptionTrace (SubscriberError {seType = SubscriberParallelConnectionCancelled, seMessage = “Parallel connection cancelled”, seStack = }))) 1s”

also i uploaded screenshot here at this link…kindly advise…

https://file.io/atMeAs2pPs2V

Block and slot number should have long gone up. They should climb immediately after starting the node.

Look like it does not connect to the testnet at all.

Does cardano-node give any errors, when it is started?

1 Like

yes sir, it gives error policy…

“[Neeraj-P:cardano.node.ErrorPolicy:Notice:50] [2022-03-24 18:34:02.49 UTC] IP 54.241.77.32:3001 ErrorPolicySuspendConsumer (Just (ConnectionExceptionTrace (SubscriberError {seType = SubscriberParallelConnectionCancelled, seMessage = “Parallel connection cancelled”, seStack = }))) 1s”

also i uploaded screenshot here at this link…kindly advise…

I don’t think the “Parallel connection cancelled” is the problem, but rather the “Version mismatch” later in your screenshot.

As said before:

You need a current version of cardano-node.

1 Like

Hello Sir, thank you so much, it worked after upgrading cardano to 1.34.1, we are finally able to install cardano on our local server and also did it on LIVE server…

sir, should i close this topic as my issue has been resolved?

But i have another question, we have a website, we want to integrate this cardano with our cart of our website, how should we do that? Because when we look at the documentation, all instructions are in CMD format but how should we bring it on our website cart system?

Should i open a new topic for it, please guide sir…

Personally, I don’t care much. The “solution” function is used very infrequently and inconsistently in this forum. Traffic is low enough that it does not really matter.

Probably better in a new topic with a more specific title.

And it’s also a very broad question.

We would have to know more. What technology stack do your developers use? What experience do they have?

A forum cannot sketch the whole application for you.

You could put a node on your web server and do cardano-cli and other invocations from the server-side part of your application. But that’s not really what I would do.

You can use blockfrost.io or similar APIs to query the blockchain from your application. They have language bindings for a lot of languages that you maybe use in your project.

1 Like

thank you so much sir for your help. I am going to mark this question as solved and going to open the new one, please do pay your attention there too…

Sir, please put in your valuable thoughts in separate ticket I opened…

Just want to know, how should I call this cardano CLI in our shop store we did in PHP…

Just to add we have integrated this cardano CLI link…

"Listening for Ada payments using cardano CLI "