errors I got in meta mask !! Help me!! #90
shaikasadahmed2k23
started this conversation in
General
Replies: 1 comment
-
|
The image you shared shows that you are running the process on the main Ethereum chain. Please ensure that you have your |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Following are my questions:
I am building the buy me a coffe projct on cyfrin updraft and issue I got are below :
below is my index-js.js
`// console.log("Hello");
import {createWalletClient,custom,createPublicClient,parseEther,defineChain} from "https://esm.sh/viem"
import { contractAddress,abi } from "./constants-js.js";
const connectButton = document.getElementById("connectBtn");
const fundBtn = document.getElementById("fundBtn");
const ethAmountInput = document.getElementById("ethAmount");
let walletClient
async function connect() {
if(typeof window.ethereum !== 'undefined') {
walletClient = createWalletClient({
transport: custom(window.ethereum)
})
await walletClient.requestAddresses()
connectButton.innerText = "Connected"
console.log("Connected to Metamask");
}
else{
console.log("Please install Metamask");
}
}
async function fund(){
const amount = ethAmountInput ? ethAmountInput.value : null
console.log(
Funding with ${amount} ETH);if(typeof window.ethereum !== 'undefined') {
walletClient = createWalletClient({
transport: custom(window.ethereum)
})
const [connectedAccount ] = await walletClient.requestAddresses()
const currentChain = await getCurrentChain(walletClient)
if (!amount) {
console.log('Please enter an ETH amount to fund');
return
}
}
else{
console.log("Please install Metamask");
}
}
async function getCurrentChain(client) {
const chainId = await client.getChainId()
const currentChain = defineChain({
id: chainId,
name: "Custom Chain",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
rpcUrls: {
default: {
http: ["http://localhost:8545"],
},
},
})
return currentChain
}
connectButton.onclick = connect
if (fundBtn) fundBtn.onclick = fund
`Beta Was this translation helpful? Give feedback.
All reactions