1

I uploaded a smart contract to the Aleph Zero test net.

When I tried to query one of the methods of said smart contract, I encountered this error:

2022-08-09 09:34:28        API/INIT: RPC methods not decorated: alephNode_emergencyFinalize
2022-08-09 09:34:28        API/INIT: aleph-node/30: Not decorating unknown runtime apis: 0x2be3f75b696ad1f6/1

This post answers, what the problem is, however I have problems implementing the solution.

const provider = new WsProvider('wss://ws.test.azero.dev');

const api = await ApiPromise.create({ provider,
    rpc: {
        firstModule: {
            myMethod: {
                description: 'Returns AccountId',
                params: [],
                type: 'AccountId'
            }
      }
} });

const address = 'contract address'
const account = 'account address'

const contract = new ContractPromise(api, abi, address)

const gasLimit = 3000n * 1000000n;
const storageDepositLimit = null

const { gasRequired, storageDeposit, result, output } = await contract.query.myMethod(
    account,
    {
      gasLimit,
      storageDepositLimit,
    }
);

The code above results in the same error. The polkadot{.js} documentation suggests to call the custom RPC like this:

const { gasRequired, storageDeposit, result, output } = await api.rpc.firstModule.myMethod(
    account,
    {
      gasLimit,
      storageDepositLimit,
    }
);

However, this results in this error:

TypeError: api.rpc.firstModule.myMethod is not a function

How can I call the method from my smart contract?

1 Answer 1

1

Ok, this problem was completely on me.

I censored the contract address, so it is impossible to know, but I put in the hash for the contract and not the actual address.

Changing 'address' to the actual contract address and putting a 'gasLimit' of 5000000000000 made the declaration of a custom RPC unnecessary and I was able to call the methods.

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.