Hello Everyone, I have deployed a smart conract to Polygon Mumbai using MetaMask. My smart contract has a receive() external payable function for empty calldata (and any value). I want to do a simple transaction with the smart contract as I can do in Remix by entering a value and then clicking the transact button. Can âMoralis.transfer()â function be used for this transaction or do I need to use something else?
I couldnât find information on this so I assumed transfer function could be used. However, I also couldnât figure out how to use matic in mumbai testnet for this. I donât know what to put for the âcontractAddressâ. When the type is erc20 it doesnât even interact with the MetaMask and If i try native for the type It just fails to complete the transaction ->>
â>>
->>>
async function buy(amount){
// const tokenInfo = { chain: "mumbai", symbols: "MATIC" };
// const tokenMetadata = await Moralis.Web3API.token.getTokenMetadataBySymbol(tokenInfo);
// const contractAddress = tokenMetadata?.address;
const options = {
type: "erc20",
amount:Moralis.Units.Token("0.001", "18"),
receiver: "0x..",
contractAddress: "0x.." //???
}
let result = await Moralis.transfer(options)
alert(result);
}
------------------------------------------------EDIT------------------------------------------------------
I have solved the issue. Moralis.transfer() with native type works perfectly. I had an issue with the logic in the smart contract. If theres is a problem with the logic in the receive() function it fails and reverts the execution!