I create a smart contract using ink! v4.2 and deploy it using contracts-ui.substrate.io Then in my front (which uses @polkadot/api-contract: 10.7.2, @polkadot/api: 10.7.2) I run this code:
await ApiPromise.create({ new WsProvider("wss://ws.test.azero.dev"), signer: connectedAccount });
const contract = new ContractPromise(api, abiDataJson, contractAddress);
Where,
api: is correct for sure
abiDataJson: json generated in /target/ink after run cargo contract build --release
contractAddress: obtained in contracts-ui.substrate.io in the part that shows "You instantiated this contract 5...", just below the title of the smart contract name
And when I run
const { gasRequired, storageDeposit, result, output } = await contract.query.totalSupply(account.address, { gasLimit: -1, storageDepositLimit: null });
console.log('result.toHuman(): ', result.toHuman());
console.log("output: ", output);
I obtain
result.toHuman(): {Err: {…}}
output: null
I think the error might be related to contractAddress, because if I put a different addres I get the same thing. In addition, the smart contract is deployed successfully as it works by calling it from contracts-ui.substrate.io
Anybody know where the error is? Thanks in advance :)