> ## Documentation Index
> Fetch the complete documentation index at: https://docs.4mica.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sponsor a deposit

> Submit a signed ERC-20 deposit into the Treasury with the facilitator paying gas.

`POST /deposit`

The payer signs an authorization off-chain and the facilitator's relayer submits the deposit and pays the gas. Collateral is credited to the signer, never to the relayer: the signature binds the destination and the amount, so the facilitator can only decide whether to submit.

Two authorization types are accepted. Send exactly one.

* **EIP-3009** (`authorization`): a `receiveWithAuthorization` signature. Works for tokens that implement EIP-3009, such as USDC.
* **Permit2** (`permit2Authorization`): a `PermitTransferFrom` signature. Works for any ERC-20 once the payer has approved Permit2. Add `eip2612Permit` to grant that approval by signature when the token supports EIP-2612, so the payer needs no gas at all.

Native ETH cannot be deposited this way. The SDKs build and sign these bodies for you; see the deposit section of each SDK's client operations page.

`POST /deposit/verify` takes the same body, runs every check without broadcasting, and answers with the [`/verify` response shape](https://docs.4mica.io/api-reference/facilitator/verify#responses).

## Request body

**network** `string`

CAIP-2 network ID. When omitted, the facilitator uses the first network it serves whose core accepts the asset. Send it.

**asset** `string` *required*

Token address.

**amount** `string` *required*

Base units, decimal or `0x` hex. Must equal the signed amount and be greater than zero.

**assetTransferMethod** `string`

Optional. It must agree with the authorization you send.

**authorization** `object`

EIP-3009 authorization: `from`, `validAfter`, `validBefore`, `nonce`, `v`, `r`, `s`.

**permit2Authorization** `object`

Permit2 authorization: `from`, `nonce`, `deadline`, `signature`.

**eip2612Permit** `object`

Only with `permit2Authorization`: `value`, `deadline`, `v`, `r`, `s`.

## Responses

Every request the facilitator can parse returns `200`. Read `success`. The facilitator waits for the transaction's receipt before it answers.

**success** `boolean` *required*

**transaction** `string`

Transaction hash. Present on success, and on a failure that happened after broadcast.

**network** `string`

The network the deposit was sent on. Present on success.

**from** `string`

The address credited. Present on success.

**asset** `string`

**amount** `string`

Base units, decimal.

**errorReason** `string`

A machine-readable reason code. Present on failure.

**errorMessage** `string`

**extra.retryable** `boolean`

Whether repeating the same request later may succeed. Present on failure.

**extra.details** `object`

Present for `permit2_allowance_required`: what the payer must approve.

```bash cURL theme={null}
curl -X POST "https://testnet.payment.4mica.io/deposit" \
  -H "Content-Type: application/json" \
  -d '{
    "network": "eip155:84532",
    "asset": "0xba50Cd2A20f6DA35D788639E581bca8d0B5d4D5f",
    "amount": "5000000",
    "authorization": {
      "from": "0x1111111111111111111111111111111111111111",
      "validAfter": "0x0",
      "validBefore": "0x6b0f1a80",
      "nonce": "0x6666666666666666666666666666666666666666666666666666666666666666",
      "v": 27,
      "r": "0x7777777777777777777777777777777777777777777777777777777777777777",
      "s": "0x8888888888888888888888888888888888888888888888888888888888888888"
    }
  }'
```

```javascript title="Fetch" theme={null}
const response = await fetch("https://testnet.payment.4mica.io/deposit", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ network: "eip155:84532", asset, amount, authorization }),
});
console.log(await response.json());
```

```python Python theme={null}
import requests
body = {"network": "eip155:84532", "asset": asset, "amount": amount, "authorization": authorization}
print(requests.post("https://testnet.payment.4mica.io/deposit", json=body).json())
```

```json 200 Deposited theme={null}
{
  "success": true,
  "transaction": "0x9999999999999999999999999999999999999999999999999999999999999999",
  "network": "eip155:84532",
  "from": "0x1111111111111111111111111111111111111111",
  "asset": "0xba50cd2a20f6da35d788639e581bca8d0b5d4d5f",
  "amount": "5000000"
}
```

```json 200 Refused theme={null}
{
  "success": false,
  "errorReason": "insufficient_funds",
  "errorMessage": "0x1111111111111111111111111111111111111111 holds 0 of 0xba50Cd2A20f6DA35D788639E581bca8d0B5d4D5f, needs 5000000",
  "extra": { "retryable": false }
}
```

## Reason codes

| `errorReason` | Meaning |
| - | - |
| `invalid_payload` | The body is malformed, or core does not accept the asset on the network. |
| `unsupported_transfer_method` | `assetTransferMethod` is neither `eip3009` nor `permit2`. |
| `invalid_signature` | The signature is malformed or does not recover to `from`. |
| `authorization_expired` | The authorization's validity window has ended. |
| `authorization_not_yet_valid` | The authorization's validity window has not started. |
| `nonce_already_used` | The authorization was already spent. |
| `insufficient_funds` | The signer does not hold the amount. |
| `permit2_allowance_required` | The signer has not approved Permit2 for the token. |
| `simulation_reverted` | The deposit would revert. `errorMessage` carries the contract's reason. |
| `sponsorship_unavailable` | The facilitator is not set up to sponsor gas on this network. |
| `relayer_underfunded` | The relayer cannot pay for gas right now. |
| `gas_ceiling_exceeded` | The deposit needs more gas than the facilitator sponsors. |
| `rate_limited` | Too many requests. Retry shortly. |
| `duplicate_in_flight` | The same authorization is already being submitted. |
| `chain_unavailable` | The chain, or this network's core or gas relayer, could not be reached. Retry shortly. |
| `broadcast_failed` | The transaction could not be broadcast. |
| `settlement_pending` | The transaction was broadcast but its receipt could not be read. `transaction` carries the hash: check it before you sign again. |
| `invalid_transaction_state` | The transaction was mined and reverted. |

## Status codes

| Code | Description |
| - | - |
| `200` | The facilitator processed the request. Check `success`. |
| `400`, `415`, `422` | The body is not JSON the endpoint can parse. The response is plain text. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.