I'm trying to create a function in my smart contract that will invoke a payment from the user, for example when a button is clicked metamask will ask to confirm the 0.10 ETH payment to my contract, I understand payable functions and have tested this in remix and can pay my contract but I want to know how to 'invoke' a payment with a predefined amount of Ether and request it from the user. Thanks
Asked
Active
Viewed 653 times
1 Answers
1
Contracts cannot invoke transactions from Externally Owned Accounts (EOA) - as initiating transactions requires an (EOA) to sign with their private key. Not sure your particular application, but could it be solved with an escrow contract? As the user could send funds to an escrow to hold until the main contract required and then possibly be sent. Also, if you only want to accept transactions that carry a certain value, you would use:
function userSendsEth() {
require(msg.value > someamount)
//Any additional functionality
}
Karen S
- 432
- 3
- 12
someamount. – Karen S Jan 29 '18 at 01:30