All Questions
Tagged with javascript metamask
110 questions
17
votes
4
answers
17k
views
How to automatically get user's wallet info if they are connected but NOT show the metamask pop up if they are not?
I don't want metamask to pop up on page load forcing a user to connect, so we only connect via a button - but after a user is connected if they refresh the page - they need to press the button again ...
16
votes
6
answers
26k
views
Better pattern to detect web3 default account when using metamask
Context: I want to use blockies to render an identicon on the page, i get the defaultAccount from web3, for this, the user has to be logged on to metamask with a selected address from his wallet.
The ...
11
votes
7
answers
18k
views
How to check whether MetaMask is installed?
How to check from client-side JavaScript whether MetaMask is installed?
9
votes
1
answer
9k
views
How to programatically change the current network with MetaMask
I would like to have a button that switches between main net and ropsten on my app, in order to do so I need to programatically change the current network with MetaMask. But I cannot find aby ...
5
votes
4
answers
3k
views
Can't get Metamask account in javascript
The command:
web3.eth.accounts
Returns an empty array despite Metamask having one account, how should I be retrieving the accounts in a way that will work with Mist and Metamask?
4
votes
1
answer
1k
views
Metamask - Infura problem. Cannot read property 'currentProvider' of undefined
I got a problem. I am using code below to connect to the eth from node.js app. Everything works perfect as long as I have installed MetaMask in my browser. I can be logged in, logged out, all good ...
3
votes
1
answer
9k
views
Window.ethereum undefined on tab with local webpage
I have the metamask extension. When I do typeof(window.ethereum) in the console for a chrome tab, I get the type as object. However if I open mywebpage.html in a tab, which is just a heading around:
&...
3
votes
1
answer
8k
views
'ALERT: Trying to call a function on a non-contract address' Why Do I Keeping This Error?
This is the error from metamask directly:
This is the error I get once after I submit the information to IPFS:
My Smart Contract:
pragma solidity 0.5.3;
//Imports for safe math operations
import "...
3
votes
1
answer
559
views
Viem wallet client method does not exist / is not available
I am trying to interact with a smart contract from a front-end web app using viem.
I am successfully creating a Wallet Client with my wallet address, but when I call some of its methods, I get the ...
3
votes
2
answers
2k
views
MetaMask API - How to detect if token already registered?
I'd like to prevent a user from entering my dapp until they have registered my token with MetaMask.
I accomplish this using the code below, which is executed the moment the user is about to enter the ...
3
votes
1
answer
946
views
Error contract code couldn't be stored, please check your gas amount
I get an error: Error contract code couldn't be stored, please check your gas amount.
I know this error has been reported several times already. Strange thing is, until this morning, my dApp just ...
3
votes
0
answers
258
views
Where is the latest MetaMask hello world dapp example?
MetaMask recently added a new permissions check. I'd like a copy-pasteable hello world dapp that includes all best practices and can check the balance of the current user's ERC20 balance for some ...
3
votes
2
answers
4k
views
Estimate Gas Cost before SendTransaction [duplicate]
How meta estimating gas cost before broadcasting.
How can I calculate gas cost for myfunc() in web3js?
function myfunc(){
require(msg.sender == owner)
...
}
await contractInstance.myfunc....
2
votes
1
answer
2k
views
How does MetaMask save our mnemonic phrase? Is it safe enough?
How does MetaMask save our mnemonic phrase? Is it saved in browser local storage? Does it encrypt our mnemonic phrase?
2
votes
1
answer
2k
views
Fake an address from my browser / metamask
I want to use a website as an ethereum address that I don't control, so I can get calldata for some specific transaction(s) from that address.
In my chrome JS console, I can do window.ethereum....
2
votes
1
answer
3k
views
How to get privateKey from Metamask by code? [closed]
Try to create ether wallet by privateKey from Metamask account
2
votes
2
answers
6k
views
Integrating MetaMask function into Wix Website
I am currently working in part on an NFT project, and I am the web designer for it. Most things are coming together nicely, yet I am now experiencing issues with MetaMask integration. I'm not a ...
2
votes
1
answer
2k
views
Encryption using public key from eth_getEncryptionPublicKey metamask function
I'm trying to encrypt data/files before uploading them to IPFS and I want to do this using metamask provided public and private keys. For this, I have tried using eth_getEncryptionPublicKey but this ...
2
votes
1
answer
4k
views
How Can You Find the Ethereum Provider on Web3 Browsers Other Than MetaMask?
MetaMask provides the following way currently to find a provider for their upcoming 2020 breaking change:
// Running on the page, in the browser
// This API will go live in Q1 2020
// It will be the ...
2
votes
2
answers
2k
views
How to detect the specific wallet provider used by the user in a web3 dapp when multiple wallet providers are installed?
I want to detect which wallet provider has been used to connect to a specific dApp.
right now what I'm doing is
const ethereum = window.ethereum;
const web3 = window.web3;
if (ethereum && ...
2
votes
1
answer
2k
views
wallet_addEthereumChain is not working in metamask android app
I am using wallet_addEthereumChain RPC function to add the custom network in metamask android app through our Dapp but it is showing an error wrong chainid. The chainid(80001) is correct and the code ...
2
votes
1
answer
1k
views
Where to define the MetaMask window.ethereum.on Listener
I have tried to include the window.ethereum.on listener to detect account changes in MetaMask, in my mounted () {} method. When the listener is triggered, it itself triggers the location.reload() ...
2
votes
2
answers
5k
views
Authenticating a user via MetaMask (like Cryptokitties)? [duplicate]
I'm trying to understand how a user could be authenticated (like a sign in) using MetaMask, similar to how Cryptokitties makes you sign up/login?
From what I understand, we need to have the user sign ...
2
votes
0
answers
412
views
MetaMask RPC API 'This message cannot be decrypted' using eth_decrypt
I am attempting to encrypt an image, post to IPFS, get the image back from IPFS and decrypt. I have successfully achieved this with string data with no issues. When I try to do the same with image ...
2
votes
2
answers
3k
views
disconnect wallet from metamask using ethers js
I've created a website on WIX (a web editor) and thought that I could add my code to engage with metamask and the smart contract that I've created, turnes out that wix doesn't support web3 so I ...
2
votes
1
answer
4k
views
Using vanilla javascript with web3 and metamask
I have searched severally on how to use web3 with metamask without nodejs without any success.
I want to be able to get an instance of a user's metamask account through web3 and vanilla javascript ...
2
votes
0
answers
174
views
How shoud I properly initialize DApp and get account address?
I am writing DApp in react, and basically I want to initialize web3, unlock account, and display it. Having web3 in my package.json In the onload I've tried to go following:
let Web3 = require('web3')...
2
votes
1
answer
587
views
Watch pending transactions with ethjs.js
I am trying to use ethjs.js to listen to pending transactions, but nothing really worked. Does anyone have a working example fetching pending transactions with ethjs.js?
I have tried the following:
...
1
vote
1
answer
4k
views
Web3 Error: no synchronous methods without callback parameter
I try to load the Metamask Web3 object into my react/redux frontend. On page load i encounter the following error:
inpage.js:233 Uncaught Error: The MetaMask Web3 object does not support synchronous ...
1
vote
1
answer
3k
views
I am getting the following error : RPC Error: Invalid parameters: must provide an Ethereum address
I am getting the following error: RPC Error: Invalid parameters: must provide an Ethereum address.
It is a simple code to send transactions using a metamask chrome extension.
<script>
let ...
1
vote
2
answers
516
views
Get current metamask account method not working anymore
I was using the following method to access the selected account on metamask through web3 v1:
//metamask method that refresh the active account in the web
this.web3.currentProvider....
1
vote
1
answer
186
views
Bundling web3js does not seem to work (Metamask app)
(This is a follow-up question from here.)
From the Metamask developers faq it is stated to "bundle the version of web3 that is used during development".
So I downloaded a web3.min.js version 0.20.6 ...
1
vote
1
answer
4k
views
How can I open an URL in Metamask explorer from a mobile navigator website?
How to open the URL of web3 in the Metamask explorer from a href link in that web3?
1
vote
1
answer
443
views
Metamask retrieve next transaction nonce
I am testing a smart contract that requires a nonce for every single method I invoke.
My idea was to use the Metasmask transaction nonce of the connected account, but I do not know how to extract the ...
1
vote
1
answer
967
views
How to convert to 8 digits in etherum
I have a token that has 8 digits, so the output is 4762575931 instead of 47.62575..
How can i change this so this works on UI and for metamask input?
I know there is the function to wei but this is ...
1
vote
2
answers
2k
views
MetaMask Web3 object does not support synchronous methods without a callback parameter [duplicate]
I'm new around here and would appreciate some intuitive help.
I wrote a contract and made a UI for it, and it's all working fine with ganache-cli. However, now that I've launched it on Ropsten and on ...
1
vote
1
answer
1k
views
Metamask Payment in Reactjs
I'm trying to implement a really basic and simple metamask payment in reactjs. This is what i done, handleClick is triggered by a button:
handleClick = () => {
let web3 = new Web3();
...
1
vote
1
answer
1k
views
How to fix "MetaMask no longer injects web3" & "Cannot read properties of undefined (reading 'toWei')" errors when using Drizzle for building a Dapp?
I'm trying to build a decentralized app for a lottery smart contract, deployed on a local ganache ethereum network, but in this case I'm using Drizzle tool from Truffle Suite.
This is the smart ...
1
vote
2
answers
1k
views
Interacting with metamask from Javascript. Etherum is not defined
Im trying to implement a very basic Metamask integration to show balances.
Im working with GoDaddy's website builder which allows you to inject arbitrary html into the of the page.
This is the code ...
1
vote
2
answers
1k
views
I am getting Returned error: VM Exception while processing transaction: invalid opcode error
I am getting an Invalid Opcode error while calling the refundAmount function which will refund the amount to the customer and cancel his/her ticket bookings. registrations is a structure mapping and ...
1
vote
1
answer
1k
views
How to listen to Metamask Ethereum events
I am trying to listen to the chainChanged event for Metamask, but the event never fires. When running the following snippet, I get a console.log of the chainId once, but the chainChanged event never ...
1
vote
1
answer
2k
views
I'm getting "Cross-Origin Request Blocked" error
I'm getting this error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at http://localhost:8545/. (Reason: CORS request
did not succeed).
I'm aware ...
1
vote
1
answer
205
views
MetaMask ethereum.enable() not responding after logout. How to reactivate?
So I found out that after logging out of MetaMask. ethereum.enable() stop working and is not triggering the login prompt window. The only way to reactivate it, is by closing chrome, and start it once ...
1
vote
1
answer
905
views
How to prompt and create Smart Contract using React
Weird question, so I have created a smart contract, verified that it works, even deployed it using Web3, Metamask and HTML/Javascript. I understand that worked.
Now I am trying to integrate it into ...
1
vote
1
answer
761
views
Metamask stuck at Unknown network ID when trying to interact with local Ganache network
I'm getting unknown network ID error on transferring a token in meta mask as in the image below. I'm using local network with ganache. I can transfer from metamask account to another after ...
1
vote
1
answer
2k
views
"Updated :" How to see "output" of "web3.personal.sign" in "browser"? ("Method personal_sign not supported")
Note: I updated the html / JavaScript code according to the answer and I used THIS META MASK sample code for web3 provider. However, I receive the same error. I eventually did not understand that do I ...
1
vote
1
answer
589
views
How to bundle own web3 version and using Metamask
I am a bit of a javascript noob and have some questions about using web3js and Metamask.
My objective (for now) is to display the ether balance as displayed on my Metamask (where I am logged in).
...
1
vote
2
answers
275
views
Why i get evm revert error when calling the method from dapp front end (web3js & metamask)??? but my contract works fine on remix and bscscan
I've created a smartcontract & deployed on bsc testnet. For the past 8 weeks, i have been upgrading and testing the contract on remix and website and they always works fine. I can mint on remix ...
1
vote
0
answers
25
views
"not logged in" when metamask gets locked by password
I have a pretty standard code used by logging in via MetaMask, something similar to this:
const connectWallet = async () => {
const provider = new ethers.providers.Web3Provider(window.ethereum)
...
1
vote
0
answers
24
views
Chrome refuses to open and claims my dapp website is malicious
I just deployed a simple dapp on which users can connect their wallet and deploy their own ERC20 token. However, when I click the link of my website, Chrome doesn't open it and I get a red page ...