hello guys we were facing some issues regarding the web3 / ether.js migration… upon calling the contractCall function the code works until it gets to the .send() function. i attach a snippet of the relevant code here.
import Web3 from "web3";
import Moralis from "moralis";
import { useMoralisFile, useMoralis } from "react-moralis";
import { TokenABI, TokenAddress } from "../../contracts/TokenContract";
import { MoralisDappProvider } from "../../providers/MoralisDappProvider/MoralisDappProvider";
function Mintpage() {
const { saveFile } = useMoralisFile();
const { account, user } = useMoralis();
// let nftContractAddress = TokenAddress;
async function saveFileToIPFS(file, filename) {
await saveFile(filename, file, { saveIPFS: true }).then(async (hash) => {
console.log(hash);
return hash._ipfs;
// ipfsCover = hash._ipfs;
});
}
async function contractCall(album) {
// const web3Js = new Web3(Moralis.provider);
// const web3 = await Moralis.enableWeb3();
await Moralis.enableWeb3();
const web3 = new Web3(Moralis.provider);
const contract = new web3.eth.Contract(TokenABI, TokenAddress);
contract.methods
.createAlbum(
album.get("objectId"),
album.get("recordCount"),
"4",
album.get("recordPrice"),
album.get("royaltyPrice")
)
.send({ from: user.get("ethAddress"), gasLimit: 3000000 })
.on("error", function (error, receipt) {
// If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.
alert("Successful");
})
.on("receipt", function (error, receipt) {
//Waiting for live query then proceed to game
alert("Error");
});
}
we are getting the following error messages either with " cannot read properties of .length
or that the provider doesnt have a.send method to use
any leads on this?
i migrated to ether.js via installing moralis@latest & react-moralis@latest. one of the teammates suggested we should use npm web3 and import web3 from web3 but either way were getting error messages. any leads much appreciated…
thanks!