0

How can I modify my Clef rule to approve requests based on both a specific miner and a specific IP address in Ethereum?

Here is my current code, which approves requests from a specific miner:

function ApproveTx(req) {
    if (req.transaction.to.toLowerCase() == "0xae967917c465db8578ca9024c205720b1a3651a9") {
        return "Approve"
    }
}

What additional condition can I add to the if statement to approve requests only if they are sent from a specific IP address?

Also, I would like to know if there is a documentation or a way to print the functions and variables of the req parameter.

1 Answer 1

0

When I print the req object, I got the following information:

{
  "transaction": {
    "from": "0xB30eAE1448a6DeC2D...",
    "to": "0xB30EAe1448A6DEc2D1E...",
    "gas": "0x5208",
    "gasPrice": "0x3b9aca00",
    "maxFeePerGas": null,
    "maxPriorityFeePerGas": null,
    "value": "0x1bc16d674ec80000",
    "nonce": "0x9",
    "data": "0x",
    "chainId": "0x4deb"
  },
  "call_info": null,
  "meta": {
    "remote": "ipaddress",
    "local": "ipAddress",
    "scheme": "ipc",
    "User-Agent": "",
    "Origin": ""
  }
}

So I updated the rules to be like the following:

function ApproveTx(req) {
  const remoteIp = req.meta.remote.split(":")[0];
  if (req.transaction.to.toLowerCase() == "0xae967917c465db8578ca9024c205720b1a3651a9" && remoteIp == '159...') {
    return "Approve"
  }
  return 'Reject';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.