Hi there
Can you share a bit more?
The Rust type that you use for the parameter and the code where you serialize it and call the other smart contract could be helpful
#[derive(Serial,Deserial,SchemaType)]
pub struct PayParam {
/// id of the transaction offchain
pub id: String,
/// payer of the transaction
pub payer: PublicKeyEd25519,
/// receiver of the transaction
pub receiver: PublicKeyEd25519,
}
The issue here is changing the javascript object to string, the data field expects a string in hex; when we pass an empty string the transaction goes through and fails on chain because of a parse param error as expected. But if we try to stringify the data object, the serialization fails with the sdk and throws this error
Error: Unable to serialize parameters, due to: "simple_withdraws" -> 0 -> "data" -> Odd number of digits
at module.exports.__wbindgen_error_new (/Users/mac/con-test/node_modules/@concordium/rust-bindings/pkg/node/concordium_rust_bindings.js:1409:17)
at wasm://wasm/00748e9a:wasm-function[1054]:0x15c788
at Object.module.exports.serializeReceiveContractParameters (/Users/mac/con-test/node_modules/@concordium/rust-bindings/pkg/node/concordium_rust_bindings.js:511:14)
at serializeUpdateContractParameters (/Users/mac/con-test/node_modules/@concordium/common-sdk/lib/serialization.js:323:39)
at ConcordiumService.getCcdWithdrawMessageHash (/Users/mac/con-test/index.ts:446:67)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ConcordiumService.pay (/Users/mac/con-test/index.ts:573:27)
at async main (/Users/mac/con-test/pay.ts:13:17)
TypeError: Cannot read properties of undefined (reading 'length')
at ConcordiumService.hexToUint8Array (/Users/mac/con-test/index.ts:381:46)
at ConcordiumService.pay (/Users/mac/con-test/index.ts:575:35)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async main (/Users/mac/con-test/pay.ts:13:17)
So "data" expects a hex string encoding of your parameter, and you are currently passing the stringified json.
Instead, you need to use the schema of the contract which defines this simple_withdraws to serialize the json (data variable) into bytes and pass this as a hex string to the "data" field.