Invoke contract with parameters

Hello,
I am trying to invoke the ccdBalanceOf method of the smart contract wallet using the web SDK

    const param = wallet.publicKey;
    const context: ContractContext = {
        method: receiveName,
        contract: contractAddress,
        parameter: Buffer.from(param)

    }
    const result = await this.client.invokeContract(context);

But it keeps failing with reject reason -1.
How can I go about this?

Hello there
So the reject reason will depend on the smart contract, most of our example have -1 meaning it failed to parse the parameters, but yours might not.

You seem to be passing a Buffer for the parameter, but the SDK actually expects something of type Parameter. See docs.

Consider trying our smart contract client generator @concordium/ccd-js-gen it will generate a typescript client for the specific smart contract based on its schema.

If you want to read about the smart error code -1, I suggest reading our developer documentation:
https://developer.concordium.software/en/mainnet/smart-contracts/tutorials/piggy-bank/deploying.html#smart-contract-errors

Hello,
I used @concordium/ccd-js-gen to generate a client and from the docs

const grpcClient = …; // Concordium gRPC client from ‘@concordium/web-sdk’.
const myModule: MyModule.Type = await MyModule.create(grpcClient);

Please what goes for grpcClient
tried

const grpcClient = new ConcordiumGRPCClient()

But its expecting RpcTransport what is that?

The gRPC client is a connection to a node on the Concordium blockchain. For prototyping we provide a node on Testnet available at https://grpc.testnet.concordium.com:20000, we don’t give any guarantees of the uptime or response time. In production, you should run your own node to use instead.

Anyway, how you construct the client depends on the environment you are running this in.

If you are running this in NodeJS: Use ConcordiumGRPCNodeClient

import { ConcordiumGRPCNodeClient } from "@concordium/web-sdk/nodejs";
import { credentials } from '@grpc/grpc-js';

const creds = credentials.createSsl(); // or use credentials.createInsecure()
const grpcClient = new ConcordiumGRPCNodeClient('grpc.testnet.concordium.com', 20000, creds);

If you are running this on a website: Use ConcordiumGRPCWebClient

import { ConcordiumGRPCWebClient } from "@concordium/web-sdk";

const grpcClient = new ConcordiumGRPCWebClient('https://grpc.testnet.concordium.com', 20000);