Proxy action (gasless)

🚧

Please note you can use broadcast freely on mumbai but if you want to use it on polygon you need to be whitelisted.

This endpoint allows you to do actions like follow and collect without having to sign any approval modals. This only works if the modules assigned to those actions are free and have no cost to them.

🚧

This request is protected by authentication

hint: this means it requires an x-access-token header put in the request with your authentication token.

📘

Full code example

Free collect - https://github.com/lens-protocol/api-examples/blob/master/src/proxy-action/proxy-action-free-collect.ts

Free follow - https://github.com/lens-protocol/api-examples/blob/master/src/proxy-action/proxy-action-free-follow.ts

API Design

Free follow

mutation ProxyAction {
  proxyAction(request: {
    follow: {
      freeFollow: {
        profileId: "0x01"
      }
    }
  })
}
{
  "data": {
    "proxyAction": "7624f076-446d-4f38-8277-326b269fe8d8"
  }
}

Free collect

mutation ProxyAction {
  proxyAction(request: {
    collect: {
      freeCollect: {
        publicationId: "0x01-0x01"
      }
    }
  })
}
{
  "data": {
    "proxyAction": "7624f076-446d-4f38-8277-326b269fe8d8"
  }
}

Response

This returns a proxyActionId which is a new id linked to that event, this is important to keep as you need it to track the status of the action. You should track this behind the scenes the user does not need to be blocked or no. To them, it should look like it's done.

Tracking the proxy action status

Once you got the proxy action id you should track its status to make sure it goes all the way through.

query ProxyActionStatus {
  proxyActionStatus(proxyActionId: "7624f076-446d-4f38-8277-326b269fe8d8") {
    ... on ProxyActionStatusResult {
      txHash
      txId
      status
    }
    ... on ProxyActionError {
      reason
      lastKnownTxId
    }
    ... on ProxyActionQueued {
      queuedAt
    }
  }
}

Response

These are all the points a proxy action can go through:

  • queued = it is waiting to be picked up by the cron
  • minting = the process has started (bare in mind it may need to do > 1 tx to complete the action)
  • complete = its all done
  • failed = something went wrong with the process
{
  "data": {
    "result": {
      "queuedAt": "2022-09-23T12:45:58.790Z",
      "__typename": "ProxyActionQueued"
    }
  }
}
{
  "data": {
    "result": {
      "txHash": "0xf73a981bda4fef5dda24cf62225a3cc0807ff4d8ecbe0e0fbdf8f8470d17a751",
      "txId": "0d7f6211-a72c-4c17-a856-a1211d7bb060",
      "status": "MINTING",
      "__typename": "ProxyActionStatusResult"
    }
  }
}
{
  "data": {
    "result": {
      "txHash": "0x0ef4bd411258518da45a84ed3484bbaaac48afcc20ad1d5acf6ee025df86cb6b",
      "txId": "76bb7b84-0a66-45a9-a834-a21e1a8a07c6",
      "status": "COMPLETE",
      "__typename": "ProxyActionStatusResult"
    }
  }
}
{
  "data": {
    "result": {
      "reason": "bad things happened",
      "lastKnownTxId": "0x0ef4bd411258518da45a84ed3484bbaaac48afcc20ad1d5acf6ee025df86cb6b"
      "__typename": "ProxyActionError"
    }
  }
}
{
  "data": {
    "result": {
      "txHash": "0x0ef4bd411258518da45a84ed3484bbaaac48afcc20ad1d5acf6ee025df86cb6b",
      "txId": "76bb7b84-0a66-45a9-a834-a21e1a8a07c6",
      "status": "TRANSFERRING",
      "__typename": "ProxyActionStatusResult"
    }
  }
}

Did this page help you?