How to create a Request
How you create a Request
usually depends on whether there is some kind of authentication involved (such as moving user funds), or whether you need to add a condition to an external function call.
To recap, the interface for newReq
is:
It's also worth noting that there is also newReqPaySpecific
which has an addition parameter, payWithAUTO
. This parameter is left out in newReq
as there's a default selection for that. Currently, the default is false
, since the AUTO
token isn't live yet, but will be turned to true
at some point after the token goes live. If you need to use a specific token to pay, best to use newReqPaySpecific
.
Simplest - no condition or authentication
Say you wanted to automate 'poking' a contract, where the function being called already has some conditions built in. For example, calling me
in the following contract:
The callData
for me
can be obtained in web3.py
by (docs):
The callData
for me
can be obtained in web3.js
by (docs):
Let's go through how newReq
would be called:
target
- the address of the contract which has the function we want to call, so the deployedTouch
contract addressreferer
- to keep it simple, it can be set to0x00...00
callData
- the calldata for callingme
, as generated aboveethForCall
- we don't want to send any ETH tome
, and even if we did, it would revert because the function is notpayable
, so this should be0
verifyUser
- since this requires that the first argument tome
is the user's address for authentication, which isn't required here (and would also revert anyway sinceme
doesn't accept any inputs), this needs to befalse
value
- this obviously isn't a direct input the thenewReq
function, but it's the amount of ETH to be sent with thenewReq
transaction that is actually sent by the user immediately when registering theirRequest
. Here, since we don't need to send any ETH totouch.me
directly, and because we want to pay for the execution in ETH, we only need to send enough ETH for the execution. Doing this properly requires estimating how much gas the execution will cost, then using the worst-acceptable-gasPrice, but here we can just use 0.01 ETH for the sake of simplicity, which should be more than enough on any testnet. Any excess ETH will get sent back to the user. For example if the actual execution costs 0.002 ETH, then since the fee is0.002 * 0.3 =
0.0006 ETH, the total that the user will receive back is0.01 - 0.002 - 0.0006 =
0.0074 ETH, with the rest going to the executor
Last updated