Smart Contract Error: Unsupported instruction 0xc0

I’m developing a smart contract on concordium blockchain and when i’m using string in struct then getting this error

#[derive(Serial, Deserial, SchemaType)]
pub struct UserData {
name: String,
product_price: i64,
}

getting this error on this line
let user: UserData = ctx.parameter_cursor().get()?;

When i simply comment name: String or remove let user: UserData = then compile the code

ERROR
0: Could not validate resulting smart contract module as a V1 contract.
1: Unsupported instruction 0xc0

See Incompatibility of Concordium smart contracts with Rust 1.70 or newer

Until the next protocol is in effect (which on testnet is expected to be 21 of August) and now tool versions are released please use Rust version 1.69 or earlier.

Thank’s for your response and i fixed the issue sir,

I need one more help to understand one thing

  • How can i make my contract upgradable so we can upgrade our contract logic’s like proxy functionality?

We have a guide for making your contract upgradable here:
https://developer.concordium.software/en/mainnet/smart-contracts/guides/upgradeable-contract.html

You can also have a look at the wCCD example which is upgradable

How can i call/interact with smart contract method though back-end or node js code?

An account can interact with a smart contract using an update-contract transaction.
Here is a link for how to do such a transaction with the nodejs sdk

1 Like

Whats the public testnet node host and port to interact with my testnet deployed contract? Or need to run concordium testnet node in my local? if yes please share steps.

I want to use this concordium example.
// const [address, port] = parseEndpoint(cli.flags.endpoint);
const client = createConcordiumClient(
“127.0.0.1”,
Number(20001),
credentials.createInsecure()
);

For testing locally, you can use the public testnet node at node.testnet.concordium.com. Keep in mind that this is a free node, and we don’t give any guarantees on the uptime, so I would recommend running your own node when running some service.

It should look something like this:

const client = createConcordiumClient(
    "node.testnet.concordium.com",
    20000,
    credentials.createInsecure()
);

Why i’m getting this error in this code

  • code error line :- const schema = await client.getEmbeddedSchema(moduleRef);
    error :- Error: WASM-Module contains no schema!

Deployed contract from this :- https://sctools.mainnet.concordium.software/
Please check attach screen shot i have successfully done both step 1 and 2

Initialize contract from step 2 but getting same error

code
const moduleRef = new ModuleReference(
‘7552e5e1330963880f5904aa22c85a2fcaa46140360f8524bf7f955b9d519427’
);
const maxCost = 30000n;
const contractName = ‘data_upload’;
const receiveName = ‘data_upload.view’;
console.log(“re”, receiveName)
const schema = await client.getEmbeddedSchema(moduleRef);

I was use testnet in https://sctools.mainnet.concordium.software/ but getting same error

any update sir? As i’m facing issue in smart contract integration

That module already exists on the chain. That is what the error is telling you.

So it is already deployed, you cannot deploy it again, and there is also no point in doing so.

If i want to upgrade my contract then i need to use contract_upgrade method so can you please share one simple example for these param’s as i don’t know which value i need to pass in this?

I dont know the ModuleReference and migrate parameters. PLESE SHARE ME ONE SMALL EXAMPLE WITH JSON.

#[derive(Debug, Serialize, SchemaType)]
struct UpgradeParams {
/// The new module reference.
module: ModuleReference,
/// Optional entrypoint to call in the new module after upgrade.
migrate: Option<(OwnedEntrypointName, OwnedParameter)>,
}

Have you tried going through this tutorial?

https://developer.concordium.software/en/mainnet/smart-contracts/tutorials/smartContractUpgrade/smartContractUpgrade.html

Which parts of it are troubling you?

Why I’m getting this error?

Error: Struct(Named([(“user_id”, String(U32)), (“user_type”, String(U32)), (“user_details”, String(U32))])) → Failed to deserialize String(U32) due to: Parsed length 4353 for String value, but unexpectedly read 73 bytes - from position 0 of bytes 01110000006a61677665657240676d61696c2e636f6d04000000616161612b0000006e616d653a6a6167766565722c656d61696c3a6a61677665657240676d61696c2e636f6d2c646f623a3135

Code
const returnValue = deserializeReceiveReturnValue(
rawReturnValue,
schema,
‘data_upload’,
‘view_with_addresss’
);

Are you sure you are using the correct schema?

The error indicates that either the contract serialized the data incorrectly, or you are supplying an incorrect schema.

How can i convert AccountAddress to Address in NodeJS?

const walletFile = readFileSync(cli.flags.walletFile, ‘utf8’);
const wallet = parseWallet(walletFile);
const sender = new AccountAddress(wallet.value.address);

Here sender is AccountAddress type but i want to convert sender as AccountAddress to pass in smart contract?

How can i get identityObject of my wallet?

please share some example of code so that i can create sub admin wallet for my team or users?

I have created alice account from my main wallet than how can i see balance of alice account as when i’m trying to check balance on ccdscan of alice account than its showing main wallet address.

Alice wallet :- 4oXY6b3ChXKV6rpxSdTi5JgT4axW1Mm1uGg2bjTA7AbcaoCUY6
Main wallet :- 4oXY6b3ChXKV6rpxSdTi5JgT4axW1Mm1uGg2bjTAATUYrYsiD5

What do you mean exactly? What is a “sub admin wallet”?