syntax: Does anyone know how to send a payable function with a fixed amount? #420
-
I would of imagined it would have been something like
The compiler doesn't seem to agree... I'm sure theirs a way to do it, Err, I must of been really tired when I wrote that. i mean like having
So its a one click wonder with a payable transation without having to manually enter a value When i change It works when I get the value for test and manually send the transactions with eth When I try to call the function within another function such as If that makes sense. Use Cases: Proxy transactions. Some other concepts would be like instead of using a require/if statement, a payable transaction could possibly only be sent with a certain amount of eth I was thinking about creating an EIP, if its not possible |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You are missing something bro function donate() public payable(uint256 amount) {
//logic
} then inside your logic you can make the validation to make sure the amount you desired is passed before function executes . example below function donate() public payable(uint256 amount) {
require(msg.value == 1 ether, 'Amount must be equal to 1 ether')
//remaining logic
}
|
Beta Was this translation helpful? Give feedback.
-
And you can access amount using special variable (only accessible in |
Beta Was this translation helpful? Give feedback.
-
Something like this would require 1 ETH function donate() public payable {
require(msg.value == 1 ether, 'Amount must be equal to 1 ether');
//remaining logic
} |
Beta Was this translation helpful? Give feedback.
Something like this would require 1 ETH