I implemented this:
const ABI = [{ ... }]
// connect to Moralis server
const serverUrl = "https://eh...ot1.usemoralis.com:2053/server";
const appId = "hQp...ciq";
Moralis.start({
serverUrl,
appId
});
const NODE_URL = 'https://speedy-nodes-nyc.moralis.io/7d...e3/eth/rinkeby'; //Rinkeby
const contractID = "0x40...9Dd";
const web3 = new Web3("http://127.0.0.1:5500");
const contract = new web3.eth.Contract(ABI, contractID);
const senderAddress = "0xC...e38"; //user who mints
const receiverAddress = contractID;
async function moralisWeb3() {
// Get the EthersJs library
const ethers = Moralis.web3Library;
// Get a (ethers.js) web3Provider
const web3Provider = await Moralis.enableWeb3();
// Enable web3 and get the initialized web3 instance from Web3.js
await Moralis.enableWeb3();
const web3Js = new Web3(Moralis.provider);
// connector
const web3 = await Moralis.enableWeb3();
const options = {
contractAddress: contractID,
functionName: "mint",
abi: ABI,
params: {
_mintAmount: "2"
},
// msgValue: Moralis.Units.ETH("0.1")
};
const transaction = await Moralis.executeFunction(options);
const receipt = await transaction.wait();
console.log(receipt)
}
But for me there are only errors…
- MetaMask - RPC Error: execution reverted
- Uncaught (in promise) Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={“code”:-32000,“message”:“execution reverted”}, method=“estimateGas”, transaction={“from”:“0xC…e38”,“to”:“0x4…9Dd”,“data”:“0xa…002”,“accessList”:null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.5.2)