> For the complete documentation index, see [llms.txt](https://sodex.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sodex.com/documentation/for-developers/api-reference/mirror-api/sponsored-withdrawal.md).

# Sponsored Withdrawal

Submit a user-signed `WithdrawToken` permit through Gateway. Gateway pays the ValueChain gas fee; the user still authorizes the withdrawal with a signature. This is not the [Transaction Relayer](/documentation/for-developers/developers/valuechain-evm/relayer.md).

## Submit a withdrawal

`POST /user/{userAddress}/evm-withdraw`

```bash
curl -X POST \
  "https://mainnet-gw.sodex.dev/api/v1/user/0x1111111111111111111111111111111111111111/evm-withdraw" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "cmdData": "0x...",
    "nonce": "123",
    "deadline": "1780000000",
    "signature": "0x..."
  }'
```

### Request body

| Name        | Type   | Required | Description                                                  |
| ----------- | ------ | -------- | ------------------------------------------------------------ |
| `cmdData`   | string | Yes      | ABI-encoded `WithdrawToken` command data with a `0x` prefix. |
| `nonce`     | string | Yes      | Nonce included in the permit signature.                      |
| `deadline`  | string | Yes      | Permit expiration included in the signature.                 |
| `signature` | string | Yes      | User permit signature with a `0x` prefix.                    |

Do not send `to` or `cmdType`. Gateway fixes them to the withdrawal handler and `WithdrawToken` command.

## Build the permit

Encode `cmdData` in this order:

| Position | Value                                                                                                                                                                                                                 |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1        | Canonical `assetName` from Asset Configuration.                                                                                                                                                                       |
| 2        | Exact destination chain identifier.                                                                                                                                                                                   |
| 3        | Case-sensitive receiver. If a memo/tag is required, use `${address}:${memo/tag}`. See [Encode the receiver](/documentation/for-developers/developers/mirror-protocol/lifecycle/withdrawals.md#3-encode-the-receiver). |
| 4        | Raw integer amount after applying asset decimals.                                                                                                                                                                     |
| 5        | Route type: `0` for custody or `1` for bridge.                                                                                                                                                                        |
| 6        | Route-specific memo value; use an empty string when unused.                                                                                                                                                           |
| 7        | Whether funds should return to CLOB if external execution fails.                                                                                                                                                      |

Read the user's nonce from the Mainnet permit contract `0x890B7D142841065E64E5f94a455876e6352A7801` using `nonces(address owner, uint192 key)`. Call `hashCallForPermit` on that contract with target `0x441BDb33C7d6DC49f627a42c3d71671D50DC2e94`, command `WithdrawToken`, the encoded command data, nonce, and deadline, then sign the returned hash.

## Response

```json
{
  "code": 0,
  "timestamp": 1780000000000,
  "data": {
    "txHash": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "senderAddress": "0x1111111111111111111111111111111111111111",
    "senderNonce": 123
  }
}
```

This response confirms only that Gateway submitted the ValueChain transaction. Track final external settlement with the [History & Status API](/documentation/for-developers/api-reference/mirror-api/history-and-status.md).

## Integration guide

{% content-ref url="/pages/JQIMBpbo8FnBHw8Jnflo" %}
[Withdrawals](/documentation/for-developers/developers/mirror-protocol/lifecycle/withdrawals.md)
{% endcontent-ref %}
