Search code examples
pythonblockchainethereummetamaskpyscript

PyScript: Checking if Metamask is installed on the browser with Ethereum


I am still learning about the new PyScript in browser. I was wondering if it is possible for me to allow a click button to check if MetMask account is connected. In regular JS we use to write the following: enter image description here

However, in PyScript, I am not sure how to get the same functionality. Can anyone help me with a code that demonstrate how to do this in PyScript from the browser?


Solution

  • from js import alert, window
    
    if not window.ethereum:
        alert("install metamask")