---
title: "Transfer"
description: "Move funds between your main account and its sub-accounts, or to an allowlisted main account."
---

A transfer can go:

- between sub-accounts of your main account
- between your main account and its sub-accounts
- to other main accounts you have allowlisted

See [main account and sub-accounts](../../index.md#glossary).

| | |
|---|---|
| SDK | `client.transfer(...)` |
| HTTP | `POST https://trades.<domain>/full/v1/transfer`, or `/lite/v1/transfer` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| WebSocket | method `v1/transfer` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for lite names |
| Auth | Session required ([Authentication](../../guides/authentication.md)) |
| Signed | `signature` is signed: [`Transfer`](../signing/Transfer.md) / [`TransferV2`](../signing/TransferV2.md) / [`TransferV3`](../signing/TransferV3.md). If from_wallet_type and to_wallet_type are both set: TransferV2 when the currency id fits uint8 (\<= 255), else TransferV3. If neither is set: Transfer (only for currency ids \<= 255). Setting only one is rejected. Sign TransferV3 only for currency ids above 255. ([Signing](../../guides/signing.md)) |
| Retries | Write: never retried automatically ([why](../../guides/errors-and-retries.md)) |
| Contract id | `transfer.transfer` (`RPCTransferV1`) |

## Request

Body type `ApiTransferRequest`. Fields the server fills are left out.

- `from_account_id` · lite `fa` · string (0x address) · required — The main account to transfer from
- `from_sub_account_id` · lite `fs` · string (uint64) · required — The sub-account to transfer from (0 if transferring from main account)
- `to_account_id` · lite `ta` · string (0x address) · required — The main account to deposit into
- `to_sub_account_id` · lite `ts` · string (uint64) · required — The sub-account to transfer to (0 if transferring to main account)
- `currency` · lite `c` · string · required — The token currency to transfer
- `num_tokens` · lite `nt` · string · required — The number of tokens to transfer. Decimal string, e.g. "1500.0"; up to the currency's balance_decimals. Scaled to an integer only inside the signature.
- `signature` · lite `s` · object Signature · required — The signature of the transfer
- `signature.signer` · lite `s` · string (uint256) · required — The address of the wallet that signed (`0x` + 40 hex characters). That wallet must be allowed to act for the account; for an order, to trade for the sub-account.
- `signature.r` · lite `r` · string (uint256) · required — The signature's `r`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `signature.s` · lite `s1` · string (uint256) · required — The signature's `s`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `signature.v` · lite `v` · integer (uint8) · required — The signature's `v`, 27 or 28.
- `signature.expiration` · lite `e` · string (int64 unix ns) · required — When the signature stops being valid, in unix nanoseconds, measured on the exchange's clock. At most 30 days ahead (take-profit and stop-loss orders may be accepted up to 180 days ahead); one already past fails with `2001`. On an order it is also the order's lifetime: an order still open then is cancelled with reason `EXPIRED`. The SDKs use now + 24 hours.
- `signature.nonce` · lite `n` · integer (uint32) · required — A number you choose, 0 to 4,294,967,295 (uint32), so that two otherwise identical requests have different signatures. Use a new random one for each request you sign.

  A transfer whose signed fields (nonce and expiration included) exactly repeat an earlier one is rejected, not ignored: it fails with `4007`.

  Orders are different. An exact resend of a signed order can be accepted and rest on the book, but the exchange counts fills per signed order, so all copies together never fill more than the signed size, and a resent `IMMEDIATE_OR_CANCEL` order whose first copy already filled is rejected. An order signed again (new nonce or expiration) is a new order and can fill in full again.
- `signature.chain_id` · lite `ci` · string (uint64) · required — The chain id in the signed EIP-712 domain, as a string. Testnet 326, production 325; `"0"` means the environment's chain id.
- `transfer_type` · lite `tt` · enum TransferType · required — The type of transfer
  Values: `UNSPECIFIED`, `STANDARD`, `FAST_ARB_DEPOSIT`, `FAST_ARB_WITHDRAWAL`, `NON_NATIVE_BRIDGE_DEPOSIT`, `NON_NATIVE_BRIDGE_WITHDRAWAL`, `ADHOC_INCENTIVE`, `REFERRAL_INCENTIVE`, `TRADING_DEPOSIT_YIELD_INCENTIVE`, `TGE_VESTING`, `TGE_AIRDROP`, `FEEDBACK_REWARD` ([details](../enums.md#transfertype)).
- `transfer_metadata` · lite `tm` · string · optional — The metadata of the transfer
- `from_wallet_type` · lite `fw` · enum WalletType · optional — The wallet type of the from account or sub-account
  Values: `FUNDING`, `SPOT`, `FUTURES` ([details](../enums.md#wallettype)).
- `to_wallet_type` · lite `tw` · enum WalletType · optional — The wallet type of the to account or sub-account
  Values: `FUNDING`, `SPOT`, `FUTURES` ([details](../enums.md#wallettype)).

## Response

Body type `ApiTransferResponse` (the same object is the JSON-RPC `result` over WebSocket).

- `result` · lite `r` · object ApiTransferAck · required — The Transfer response object
- `result.ack` · lite `a` · bool · required — True when the exchange has processed the transfer. If true, a `tx_id` will be returned. If false, an error will be returned.
- `result.tx_id` · lite `ti` · string (uint64) · required — The transaction ID of the transfer. This is only returned if the transfer is successful.

## Errors

Errors come back as `{"code", "message", "status"}` (lite `{"c", "m", "s"}`) with the HTTP status. Codes this call can return, as code, name (HTTP status) ([all error codes](../errors.md)):

`1000` Unauthorized (401) · `1001` Forbidden (403) · `1002` InternalServer (500) · `1003` InvalidRequest (400) · `1006` RateLimit (429, retryable) · `1008` IPNotWhitelisted (401) · `1014` GatewayTimeout (504, retryable) · `1015` ServiceUnavailable (503, retryable) · `4000` InsufficientBalanceToTransfer (400) · `4002` TransferFailedReasonUnrefined (400) · `4004` BothTransferWalletTypeMustBeProvided (400) · `4005` InvalidWalletTypeForFundingAccount (400) · `4006` InvalidWalletTypeForSubAccount (400) · `4007` DuplicatedTransfer (400) · `4008` CurrencyNotAllowedInWallet (400) · `4009` UnspecifiedTransferType (400) · `4010` WithdrawalWalletNotSupported (400) · `4011` CVRZeroNotAllowedInFuturesWallet (400) · `4012` CollateralLimitExceeded (400) · `4014` CurrencyTransferNotAllowed (400) · `4015` NoTransferPermission (403) · `4016` TransferWithdrawalBlocked (403) · `4018` GrvtExternalTransferNotAllowed (400) · `4019` WithdrawalWalletUnderReview (400) · `4020` CurrencyNotEnabledAsCollateral (400) · `4021` InsufficientFundingVaultShares (400) · `4022` InsufficientTradingVaultShares (400) · `4023` VaultShareTransferRoute (400) · `5000` InvalidTransferMetadata (400) · `5001` InvalidTransferProvider (400) · `5002` InvalidDirection (400) · `5003` InvalidEndpoint (400) · `5004` FundingAccountDoesntExist (400) · `5005` InvalidChainID (400) · `7100` UnknownTransactionType (500) · `7101` TransferAccountNotFound (400) · `7102` TransferSubAccountNotFound (400) · `7103` ChargedTradingFeeBelowConfigMinimum (500) · `7104` TransferSubAccountNotUnderAccount (400)

## Example

```python
import os
from decimal import Decimal

from grvt import Grvt, enums as e, PrivateKeySigner

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
    signer=PrivateKeySigner(os.environ["GRVT_PRIVATE_KEY"]),
) as client:
    resp = client.transfer(
        from_account_id=os.environ["GRVT_MAIN_ACCOUNT_ID"],
        from_sub_account_id="0",
        to_account_id=os.environ["GRVT_MAIN_ACCOUNT_ID"],
        to_sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
        currency="USDT",
        num_tokens=Decimal("1500.25"),
        transfer_type=e.TransferType("STANDARD"),
    )
    print(resp)
```

Raw HTTP (set `GRVT_DOMAIN`, see [Environments](../../guides/environments.md); `GRVT_COOKIE` and `GRVT_ACCOUNT_ID` come from [login](../../guides/authentication.md)):

The body below is the `transfer` signing case: a real signature by the public test key for chain id 326. Build your own with the [Signing guide](../../guides/signing.md); the server will reject this one (unknown account). `signature.expiration` is unix nanoseconds: use now + 1 day (the signing case uses 2100-01-01 so it never expires).

With full field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/full/v1/transfer" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "from_account_id": "0x0c3e7b0a6c8a1b2d3e4f5a6b7c8d9e0f1a2b3c4d",
  "from_sub_account_id": "0",
  "to_account_id": "0x0c3e7b0a6c8a1b2d3e4f5a6b7c8d9e0f1a2b3c4d",
  "to_sub_account_id": "8289849667772468",
  "currency": "USDT",
  "num_tokens": "1500.25",
  "signature": {
    "signer": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
    "expiration": "4102444800000000000",
    "nonce": 2001,
    "chain_id": "326",
    "r": "0x0239d69eb4aabc7b7135313ff34cc5c9c6ce6e68a343189181f60cb6b9fc4ff9",
    "s": "0x05f2516e72cb9531762f5cf4c7dd6de8fbbc835c56a75e79148983904c1c5590",
    "v": 27
  },
  "transfer_type": "STANDARD"
}
EOF
```

With lite field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/lite/v1/transfer" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "fa": "0x0c3e7b0a6c8a1b2d3e4f5a6b7c8d9e0f1a2b3c4d",
  "fs": "0",
  "ta": "0x0c3e7b0a6c8a1b2d3e4f5a6b7c8d9e0f1a2b3c4d",
  "ts": "8289849667772468",
  "c": "USDT",
  "nt": "1500.25",
  "s": {
    "s": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
    "e": "4102444800000000000",
    "n": 2001,
    "ci": "326",
    "r": "0x0239d69eb4aabc7b7135313ff34cc5c9c6ce6e68a343189181f60cb6b9fc4ff9",
    "s1": "0x05f2516e72cb9531762f5cf4c7dd6de8fbbc835c56a75e79148983904c1c5590",
    "v": 27
  },
  "tt": "STANDARD"
}
EOF
```
