I am pretty new to solidity, web3 and metamask.Even i am not sure if this forum to ask this question
While going through the documents metamask suggested to use window.ethereum directly intead of window.web3 and avoid injecting web3.
I reffered the below link:
https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3
I tried suing it directly for accessing my account addrese and balances.It worked fine.
But, now I want to call a solidity function which looks something like this:
function enter() public payable {
require(msg.value > 1);
players.push(msg.sender);
}
how do I call this directly through window.ethereum?
I tried the older way of accomplishing this that is by :
This worked fine.This is not the complete code, it is just a snippet.But, this not using the window.ethereum directly right?
const Web3 = require(“web3”);
window.web3 = new Web3(window.ethereum);
const lottery = await new window.web3.eth.Contract(abi, address);
await lottery.methods.enter().send({ from: accounts[0], value: web3.utils.toWei(“0.02”, “ether”), });
This worked fine.This is not the complete code, it is just a snippet.But, this not using the window.ethereum directly right?
But, this not using the window.ethereum directly right?
and I am getting a warning message in the chrome console as mentioned below:
“page.js:1 MetaMask: The event ‘close’ is deprecated and may be removed in the future. Please use ‘disconnect’ instead.”
Please suggest how to proceed on this or above mentioned approach is correct and we need to proceed with the warning.
Even i am not sure if this forum to ask this question.