The previous answer is now incorrect due to the deprecation of the RPCs.
How do we query the historic contract state now?
In the PR comment it states:
The high level contracts API in polkadot.js already uses state_call so upgrading to the latest version here is enough. If you are using api.rpc.contracts directly you need to switch to api.call.contractsApi.
However, switching to api.rx.call.contractsApi.call
does not give an option to pass at
. There is the option to create an instance of the api at a specific block but there is no explanation of how to query contracts using this.
The following does not work as the returned type of api.at
(ApiDecoration<"promise">
) is not equivalent to ApiPromise
if (atBlock) {
const atApi = atBlock ? await api.at(atBlock) : api
contract = new ContractPromise(atApi, abi, contractAddress)
}