We have decided to switch to Moralis for all things web3 in our project. So far, weāve been using plain ethers and web3-react. Iām having difficulties interacting with smart contracts and I have read all forum posts with the same question in mind, yet all answers seem pretty unsatisfying.
After āenabling web3ā, the useMoralis
hook should expose the provider, which (according to the docs) should be usable as an ethers provider to pass to a ethers Contract object. This would be ideal as we wouldnāt have to rewrite our code base.
const { provider } = useMoralis();
if (provider)
return new ethers.Contract(
config.address.marketRegistry,
marketRegistryABI,
provider
);
Yet, the provider doesnāt seem to be a valid ethersjs provider. The resulting error is: āError: invalid signer or provider (argument=āsignerOrProviderā, value=ā[object Object]", code=INVALID_ARGUMENT, version=contracts/5.6.2)", as ethersjs checks for provider._isSigner/_isProvider which is not available (setting these to true gives more errors).
The docs further describe the executeFunction API which seems unnecessarily limited (or perhaps the docs are missing). Users of our dapp should be able to deploy their own smart contracts (yet the function parameter seems to be required). Furthermore we batch all call/view requests and request them in one single encoded transaction. This also doesnāt seem to be possible.
I guess we could simply use window.ethereum for all transaction requestsā¦ Although Iām wondering whether this covers all walletsā¦ (which is one of the main reasons for using something like web3-react/moralis in the first place).
TLDR:
We would like to be able to send raw encoded transactions for call/view requests and deploy contracts using Moralis provider.