current position:Home>Taking DAPP pethop as an example, metamask needs to pay eth when adopting. How can I modify the code?

Taking DAPP pethop as an example, metamask needs to pay eth when adopting. How can I modify the code?

2022-02-03 20:54:22 Q & A of Denglian community

Hello everyone, I'm a beginner , I hope to learn and improve with you .

petshop box For example, there seems to be no need to pay money for adoption , Only consumption gas. Tried to give Adoption.sol In the contract documents adopt Function addition “payable” identification , And in app.js The code of contract interaction in “value:100”, Want to specify the price . Last use ganache and MetaMask Deploy , Although the store page came out , But a little bit adopt The button doesn't respond .( If you don't change value, The example is that you can run )

Ask the experts , Want to adopt MetaMask You need to pay a certain amount of money and gas, How to modify the code ?




Take the answer 1:

You can look at the browser console ,, When you click adopt when , What error is output .

It should be you app.js Your code is wrong .




copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032054204004.html

Random recommended