TypeError: Cannot read properties of undefined (reading 'length')
at isValidHash (/Users/alex/Documents/repos/deansart_bot/node_modules/@concordium/common-sdk/lib/util.js:96:17)
at ConcordiumNodeClient.invokeContract (/Users/alex/Documents/repos/deansart_bot/node_modules/@concordium/node-sdk/lib/client.js:466:37)
at /Users/alex/Documents/repos/deansart_bot/controllers/ethereumController.js:1434:39
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The entrypoint does not seem to expect a parameter, as you don’t provide one in concordium-client. So you shouldn’t provide a parameter in javascript either. I am not sure about the exact error message, for that, I would have to look deeper into the issue.
But you can try this:
let result = await client.invokeContract(
{
invoker: accountAddress,
contract: contractAddress,
method: methodName
}
);
This example shows how to invoke a parameter-less entrypoint on a contract:
same error:
TypeError: Cannot read properties of undefined (reading ‘length’)
at isValidHash (/Users/alex/Documents/repos/deansart_bot/node_modules/@concordium/common-sdk/lib/util.js:96:17)
at ConcordiumNodeClient.invokeContract (/Users/alex/Documents/repos/deansart_bot/node_modules/@concordium/node-sdk/lib/client.js:466:37)
at /Users/alex/Documents/repos/deansart_bot/controllers/ethereumController.js:1443:39
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: Cannot read properties of undefined (reading ‘length’)
at isValidHash (/Users/alex/Documents/repos/deansart_bot/node_modules/@concordium/common-sdk/lib/util.js:96:17)
at ConcordiumNodeClient.invokeContract (/Users/alex/Documents/repos/deansart_bot/node_modules/@concordium/node-sdk/lib/client.js:466:37)
at /Users/alex/Documents/repos/deansart_bot/controllers/ethereumController.js:1443:39
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The error happens due to a missing second function parameter of the client.invokeContract, which takes both ContractParameters and a string (block hash).
concordium-client implicitly uses the best block when no block hash is specified, whereas the nodeJS SDK requires you to specify it with no fallback.
The following code should work:
let result = await client.invokeContract(
{
invoker: accountAddress,
contract: contractAddress,
method: methodName,
parameter: inputParams
},
bestBlock
);
You can find the documentation for the specific client function here: