# /account-abstraction/operations

{% hint style="info" %}
You need an API key for this call.\
\
Please reach out to the Blessnet team to get setup.
{% endhint %}

<mark style="color:green;">`POST`</mark>`/account-abstraction/operations`

The `/account-abstraction/operations` endpoint allows the posting of ERC-4337 operations to abstract accounts via the singleton on-chain entrypoint.

### **Headers**

| Name        | Value        |
| ----------- | ------------ |
| `x-api-key` | Your API key |

### **Params**

<table><thead><tr><th width="215">Name</th><th width="130">Mandatory?</th><th width="119">Default</th><th>Value</th></tr></thead><tbody><tr><td><code>chain</code></td><td>No</td><td><code>mainnet</code></td><td>The chain type we are working with, either <code>mainnet</code> or <code>sepolia</code></td></tr></tbody></table>

### Request Body

* required: true
* content: application/json:&#x20;
* schema:&#x20;

  * `type: array`&#x20;

  ```postman_json
  {
    "ops": [
      {
        "account": <the account the operations is for>,
        "target": <the address target for the call>,
        "calldata": <the calldata to pass to the target>,
      }
    ]
  }
  ```
* description: An array of valid operations.

### **Response Body**

| Name               | Type       | Description                                                               |
| ------------------ | ---------- | ------------------------------------------------------------------------- |
| `message`          | `string`   | Message response from the endpoint                                        |
| `requestOwner`     | `array`    | The owner of the API key that made the operation request.                 |
| `for`              | `array`    | Array of operations requested, with account, target and calldata for each |
| `destinationChain` | `number`   | The target chain for the operation                                        |
| `deliveryIds`      | `string[]` | Unique Ids for the execution of the operations.                           |

### **Example Request**

```
POST /account-abstraction/operations?chain=sepolia HTTP/1.1
Host: api.bless.net
x-api-key: <>
Content-Type: application/json
Content-Length: 763

{
  "ops": [
    {
      "account": "0xa8C46f79c72DbfE885e54b5527002c515F860875",
      "target": "0x4995423334127293b31d8c810Bb183809f82Be55",
      "calldata": "0x62a61351000000000000000000000000a8C46f79c72DbfE885e54b5527002c515F860875000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    }
  ]
}
```

### **Response**

{% tabs %}
{% tab title="201" %}

```json
{
    "message": "Ops requested",
    "requestOwner": "omnus",
    "for": [
        {
            "account": "0xa8C46f79c72DbfE885e54b5527002c515F860875",
            "target": "0x4995423334127293b31d8c810Bb183809f82Be55",
            "calldata": "0x62a61351000000000000000000000000a8C46f79c72DbfE885e54b5527002c515F860875000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
        }
    ],
    "destinationChain": 11145513,
    "deliveryIds": ["67c8c05d179b8cbc49505f4e"]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "message": "Please provide chainId and delegate address as query parameters."
}
```

{% endtab %}
{% endtabs %}

### Example uses

{% tabs %}
{% tab title="ethers" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>import ethers from "ethers"
</strong><strong>
</strong><strong>const interface = new ethers.Interface(myABI)
</strong>const calldata = interface.encodeFunctionData("myFunction", [arg1, arg2])
const ops = [{
    account: myUserAccount,
    target: myContract,
    calldata,
}]

fetch("https://api.bless.net/account-abstraction/operations", {
    method: "POST",
    body: { ops }
})
</code></pre>

{% endtab %}

{% tab title="viem" %}

```typescript
import { encodeFunctionData } from "viem"

const interface = new ethers.Interface(myABI)
const calldata = encodeFunctionData({
    abi: myABI,
    args: [arg1, arg2],
    functionName: "myFunction",
})
const ops = [{
    account: myUserAccount,
    target: myContract,
    calldata,
}]

fetch("https://api.bless.net/account-abstraction/operations", {
    method: "POST",
    body: { ops }
})
```

{% endtab %}
{% endtabs %}
