current position:Home>How to ensure that the price entered by the user is appropriate

How to ensure that the price entered by the user is appropriate

2022-02-03 23:28:20 Q & A of Denglian community

To realize a contract to pay for things ,buy(uint price,uint amount), A similar function , Enter the price and quantity at the time of purchase , then msg.value It's their and , Call the contract buy, Prices change from time to time , How to judge the user in the contract, but the price submitted is correct , Instead of what he wrote casually




Take the answer 1:

The price submitted by the user needs to be verified in the contract .

Best in buy Function plus a signature referring to the real-time price ( Signed by the project party ) Information As a parameter .






Other answers 1:

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

Random recommended