Cannot deploy contract using javascript sdk

So am trying to compile and deploy a contract using js sdk. it compiles fine but and error occurs when I try to deploy and pass deploy parameters.
snippet:
const deployed = await client.contractDeploy(compiled.bytecode, ‘sophia’, {initState: ‘(10000, 15)’}).catch(logError);

Reference: https://dev.aepps.com/tutorials/smart-contract-usage-in-javascript-sdk.html.

This is the error am getting:
Error data: {“info”:{“error”:“wrong_type”,“data”:{“abi”:“sophia”,“options”:{“initState”:"(10000, 15)"}},“path”:[“arguments”]},“parameter”:“body”,“reason”:“validation_error”}

Have you tried deploying contract using new ContractInstance API?

You’d basically do something like this:

let contractSource = // ... load contract source file here
let contractInstance = await client.getContractInstance(contractSource)
let result = await contractInstance.deploy([10000, 15])

Now when you have your contractInstance deployed you can call functions like this:

let functionResult = await contractInstance.call("some_function", [param1, param2 ...])

Also which version of aepp-sdk do you use?

3 Likes