Hey Guys
Greetings!
Quick question: Does anyone know if there’s a REST API we can use to verify transactions on the Concordium blockchain by their transaction hash? I found this endpoint: https://wallet-proxy.testnet.concordium.com/v0/submissionStatus/${txnHash}, but I’m facing a couple of issues:
When we pass additional data as a hexstring during transaction initiation, it seems to add some extra characters, messing up our decoding process.
Also, this endpoint is only for the testnet, but we need something that works for the mainnet too.
grpc.testnet.concordium.com and grpc.mainnet.concordium.software are publicly provided endpoints where you can query transaction statuses/outcomes. They are meant to be used programmatically. The wallet-proxy is not.
We have a number of SDKs that make it very simple to query these statuses, both from a browser context or from other applications. See SDKs and APIs — Concordium documentation
I strongly recommend using one of those. Would that work for you?
Could you help me locate the endpoints on grpc.testnet.concordium.com and grpc.mainnet.concordium.software that allow querying for a transaction using the transaction hash? Simply visiting these sites doesn’t seem to lead me to any relevant documentation.
Also, regarding the Concordium documentation link you provided earlier, I’ve checked out the transactions section, but couldn’t find a method for retrieving transaction details using a transaction hash.
Appreciate your assistance in pointing me in the right direction!
@sderuiter this is niceee! only issue is that the parameter property which is supposed to have the data I’m sending as hexstring seems to append some additional characters to the hexstring I sent, thereby messing the decoding process on my end.
Here is an image of data property when signing the contract (notice it starts with 7b and ends with 7d)
you would notice there are additional characters - “010000c0843d00e15891347cc368764723c6248b78a8fb4c173ad54038a36e461a9639dd2d9acd008a3d892b84f72d6b113b88e593b93605596f2472ecd76bab53f8cb281d7f71109100” being added to the initial data I assed. please any idea whats causing this and how I can fix it?
Hmm, I’m reading this directly from the GRPC v2 spec as account_transaction, as in: there is no step where I add additional data to this particular field. Do you know how view the transaction in the block using Concordium-client? I can’t look right now, but I’m sure this reports the same info as the api does.
Also, are you sure you want the tx hash and not the logged events (looking at the tx type)?
@sderuiter thanks for your help so far, I was able to use getBlockItemStatus and it also returns the message the same way. Been trying to figure out why it adds the extra bytes “010000c0843d00e15891347cc368764723c6248b78a8fb4c173ad54038a36e461a9639dd2d9acd008a3d892b84f72d6b113b88e593b93605596f2472ecd76bab53f8cb281d7f71109100”, haven’t figured it out so far. currently looking through Concordium docs and Github to see if there is any util that helps extract just the initial hex string I sent to the contract
For this parsing you would use a schema to extract the relevant data using the web-sdk.
const contractName = ContractName.fromStringUnchecked('euroe_stablecoin_v3');
const functionName = EntrypointName.fromStringUnchecked('transfer');
const schema =
getUpdateContractParameterSchema(
fullSchema,
contractName,
functionName,
schemaVersion
);
const parsed = deserializeTypeValue(toBuffer(parameter), schema);
// then parsed["data"] will be your "data" field if all goes well
@abizjak thanks for all your help so far. I can see the getModuleSource(ref, blockHash) takes two parameters, the ModuleReference and the blockHash. The blockHash I’m able to get when I call getBlockItemStatus. Please how can I get the module reference (ref). I can see from Concordium example of Github, they are doing something like this
@abizjak here is my setup so far, everything works untill it gets to getUpdateContractParameterSchema, then it logs an error "Unable to get parameter schema, due to: Parse error". Please any clue what the issue could be
Almost there, you need to use the underlying buffer so fullSchema.buffer, also the schema version is only needed for older smart contracts, so you should be able to omit that part.
Edit: I realized that you want to parse the parameter, which is currently not supported by ccd-js-gen, so side note below does not apply.
On a side note:
If you only care about a specific smart contracts such as the EUROe, then consider using @concordium/ccd-js-gen to generate a typescript client for the smart contract, which generates code hiding a lot of this.