Lesson 8: Is "value" parameter inside fund() a global variable? #2250
-
From this code inside fund() , we're passing const transactionResponse = await contract.fund({
value: ethers.utils.parseEther(ethAmount), async function fund() {
const ethAmount = document.getElementById("ethAmount").value
console.log(`Funding with ${ethAmount}...`)
if (typeof window.ethereum !== "undefined") {
const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, abi, signer)
try {
const transactionResponse = await contract.fund({
value: ethers.utils.parseEther(ethAmount),
})
await listenForTransactionMine(transactionResponse, provider)
} catch (error) {
console.log(error)
}
} else {
fundButton.innerHTML = "Please install MetaMask"
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Sep 1, 2022
Replies: 1 comment 2 replies
-
@nsawit Which one
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
nsawit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@nsawit Which one
ethers
orethAmount
?ethers
is coming from this fileimport { ethers } from "./ethers-5.6.esm.min.js";
And
ethAmount
is coming from a text field that we define in the HTML.<input id="ethAmount" placeholder="0.1"> <br>