Smart Contract response


I am using the following example for credential registry,

I am invoking the credientialEntry endpoint using NodeJS, please see the relevant code below

 async function verifyContract() {
  const client = createConcordiumClient(

  const walletFile = readFileSync("/home/yasir/concordium_dev/contracts/3SfHLNkmy61ZUQkAhMvAwKj47EYDBiUPbn3wHghFD6qGr8WDGc.export", 'utf8');
  const wallet = parseWallet(walletFile);
  const sender = new AccountAddress(wallet.value.address);
  const signer = buildAccountSigner(wallet);

  const moduleRef = new ModuleReference(
  const maxCost = 30000n;
  const contractName = 'hash_reg';
  const receiveName = 'hash_reg.credentialEntry';
  // const schema = await client.getEmbeddedSchema(moduleRef);

  const rawModuleSchema = Buffer.from(readFileSync(

  const updateHeader: AccountTransactionHeader = {
    expiry: new TransactionExpiry(new Date( + 3600000)),
    nonce: (await client.getNextAccountNonce(sender)).nonce,

  const params = "9e8c6c123351c3405489b0662da9792ba8a7626ad488f571ce50373e9da31672";
  // let params1 = "{ a:1  }"
  // const params2 = Buffer.from(params);
  const updateParams = serializeUpdateContractParameters(

//   const inputParams = serializeInitContractParameters(
//     contractName,
//     params,
//     rawModuleSchema,
// );

  const updatePayload: UpdateContractPayload = {
    amount: new CcdAmount(0n),
    address: {"index":BigInt(6990),"subindex":BigInt(0)},
    message: updateParams,
    maxContractExecutionEnergy: maxCost,

  const updateTransaction: AccountTransaction = {
    header: updateHeader,
    payload: updatePayload,
    type: AccountTransactionType.Update,

  const updateSignature = await signTransaction(updateTransaction, signer);
  const updateTrxHash = await client.sendAccountTransaction(

  console.log('Transaction submitted, waiting for finalization...');

  const updateStatus = await client.waitForTransactionFinalization(
  console.dir(updateStatus, { depth: null, colors: true });
  return updateStatus;


I receive following response


If I run the invoke cmd in cli i recieve

Invocation resulted in failure:
 - Energy used: 1346 NRG
 - Reason: 'credentialEntry' in 'hash_reg' at {"index":6990,"subindex":0} failed with code -2 
 - Error value:
          "CredentialNotFound": []

How, can i get the Cli response in NodeJS?

You cannot get exactly the same output from sending the transaction.

In particular you cannot get the “Error value” part out which I assume is what you are referring to.

You can use the invokeContract function instead though, as exemplified here ConcordiumGRPCClient | Concordium JS-SDKs

In particular to pretty print the error value “CredentialNotFound” you need to use the Error schema (which you can either extract from the module or get from cargo-concordium output) here

const returnValue: string | undefined = result.returnValue; // If the invoked method has return value
        if (returnValue) {
            console.log('The return value of the invoked method:', returnValue);

and parse the returnValue into JSON.

1 Like

Thx! always great help!