1

I deploy the flipper contract to Jupiter testnet, when I try to get the contract data, I got this error message although it works just fine on a local node. (I also tested on other test networks and the error persists)

2022-02-28 10:53:34        METADATA: Unknown types found, no types for AuthorityState
2022-02-28 10:53:34        RPC-CORE: call(callRequest: ContractCallRequest, at?: BlockHash): ContractExecResult:: -32602: Invalid params: unknown field `storageDepositLimit`, expected one of `origin`, `dest`, `value`, `gasLimit`, `inputData`.
Error: -32602: Invalid params: unknown field `storageDepositLimit`, expected one of `origin`, `dest`, `value`, `gasLimit`, `inputData`.
    at RpcCoder._checkError (/home/minhnd/node_modules/@polkadot/rpc-provider/coder/index.cjs:84:13)
    at RpcCoder.decodeResponse (/home/minhnd/node_modules/@polkadot/rpc-provider/coder/index.cjs:47:10)
    at WsProvider.value (/home/minhnd/node_modules/@polkadot/rpc-provider/ws/index.cjs:267:90)
    at W3CWebSocket.value [as onmessage] (/home/minhnd/node_modules/@polkadot/rpc-provider/ws/index.cjs:247:153)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/minhnd/node_modules/yaeti/lib/EventTarget.js:107:17)
    at W3CWebSocket.onMessage (/home/minhnd/node_modules/websocket/lib/W3CWebSocket.js:234:14)
    at WebSocketConnection.<anonymous> (/home/minhnd/node_modules/websocket/lib/W3CWebSocket.js:205:19)
    at WebSocketConnection.emit (node:events:520:28)
    at WebSocketConnection.processFrame (/home/minhnd/node_modules/websocket/lib/WebSocketConnection.js:554:26)
    at /home/minhnd/node_modules/websocket/lib/WebSocketConnection.js:323:40

This is the code file I use to call the contracts:

const { ApiPromise, WsProvider } = require("@polkadot/api");
const { ContractPromise } = require("@polkadot/api-contract");
const { keyring } = require("@polkadot/ui-keyring");
keyring.loadAll({ ss58Format: 42, type: "sr25519" });

const abi = require("./freshdi_metadata.json");

async function main() {
    const provider = new WsProvider("wss://ws.jupiter-poa.patract.cn/");
    const api = await ApiPromise.create({ provider });

    const contractAddress = "kabwymmUkz77bD9VHPbugxv75mLHqw8hR8eLhyXFxnmKU8Z";
    const contract = new ContractPromise(api, abi, contractAddress);

    const newPair = keyring.createFromUri("my secret phrase")
    const value = 0;
    const gasLimit = 5000000000000;
    const { gasConsumed, result, output } = await contract.query.get(
        newPair.address,
        { value, gasLimit }
    );
    console.log(result.toHuman());
    console.log(gasConsumed.toHuman());

    if (result.isOk) {
        console.log("Success", output.toHuman());
    } else {
        console.error("Error", result.asErr);
    }
}

main()
    .catch(console.error)
    .finally(() => process.exit());
2
  • 1
    Sounds like your node is not compatible with your version of polkadotjs. Which node are you using?
    – forgetso
    Mar 2, 2022 at 14:54
  • @forgetso You're right. I found out that the testnet I'm using is running on an older version of substrate. I changed to a testnet with the newer version and my code works as expected.
    – Minh Mốc
    Mar 2, 2022 at 15:49

1 Answer 1

2

I found the reason: Compatibility issue. The testnet I was trying to connect to used an older version of substrate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.