I am trying to use the ContractPromise
from @polkadot/api-contract
to interact with a published smart contract on the moonriver network but when I try and create a new ContractPromise
object I get the error
Error: createType(ContractProjectInfo):: Struct: Unable to map" + abi string + "array to object with known keys source, contract"
I'm not entirely sure why this is because the ABI and contract address seem to be correct.
The code I am using to test it out is here:
import { ApiPromise, WsProvider } from "@polkadot/api";
import { ContractPromise } from "@polkadot/api-contract";
import { ksmContractABI } from "./consts";
async function main() {
console.log("start");
const ksmContractAddress = "0xFfc7780C34B450d917d557E728f033033CB4fA8C";
const wsProvider = new WsProvider("wss://kusama-rpc.polkadot.io");
const api = await ApiPromise.create({ provider: wsProvider });
const contract = new ContractPromise(
api,
JSON.stringify(ksmContractABI),
ksmContractAddress
);
console.log("done");
}
the contract can be seen here: https://moonriver.moonscan.io/address/0xFfc7780C34B450d917d557E728f033033CB4fA8C
and the code from which I generated my abi can be found here: https://github.com/mixbytes/lido-dot-ksm/blob/main/contracts/Lido.sol
@polkadot/api-contracts
cannot interact with Ethereum-like contracts, only those using the Substrate contracts pallet. In this case it would seem, since you are trying on Moon*, it is an Ethereum-like contract. (To verify, sharing your ABI would be useful)kusama-rpc.polkadot.io
. This Kusama and not Moonriver. Parachains have their own endpoint. You do not connect through their relay chain.