Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

connecting to user wallet using metamask javascript

//metamask enject ethereum object in browser so you can easily connect.
//this is pure js way you can use ethers.js and web3.js in react.Thanks
let accounts;
const enableEth= async()=> {
accounts= await window.ethereum.request({method:'eth_requestAccounts'})
 .catch((err)=> {
 //error handling
  console.log(err.code) //errorcode 4001 user reject request
})
  console.log(accounts); //["your connected wallet"]
}
Comment

how to connect metamask wallet with js

async function connectWallet() {
  const provider = new ethers.providers.Web3Provider(window.ethereum)
  await provider.send("eth_requestAccounts", []);
  const signer = provider.getSigner() 
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: search box enter key javascript 
Javascript :: get uploaded file name in js 
Javascript :: javascript is variable a string 
Javascript :: javascript iterate over json 
Javascript :: javascript get bit 
Javascript :: javascript regex vowel 
Javascript :: how to update all node libraries 
Javascript :: jquery change value 
Javascript :: mongodb mongoose document populate nested document 
Javascript :: regular expression for password 
Javascript :: onload set scroll on top of page jquery 
Javascript :: js camel case to snake case 
Javascript :: Adblock detection in website using javascript 
Javascript :: js remove from array by value 
Javascript :: vue local storage delete 
Javascript :: counting duplicates codewars javascript 
Javascript :: adonis andwhere 
Javascript :: remove special characters javascript 
Javascript :: cy url contains 
Javascript :: javascript json string 
Javascript :: node express send error response 
Javascript :: How to include JSPs file from another folder 
Javascript :: how to check if the user is in a certain guild in discord 
Javascript :: how to create uuid in javascript 
Javascript :: return longest string from array 
Javascript :: how to access child img src in jquery 
Javascript :: javascript redirect to 
Javascript :: javascript array distinct 
Javascript :: open json file in current directory python 
Javascript :: workbox push notifications 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =