---
title: "Transfer stream"
description: "Stream transfers into or out of your main account, or of one of its sub-accounts."
---

| | |
|---|---|
| SDK | `client.transfer_stream(...)` |
| Channel | `v1.transfer` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| Selector | `<main_account_id>[-<sub_account_id>]` |
| Auth | Session required on the WebSocket upgrade ([Authentication](../../guides/authentication.md)) |
| Kind | `event`. Each frame is one event (an update to one object). |
| Sequenced | Yes: the first update's `prev_sequence_number` is at or below the subscribe reply's `latest_sequence_number`, then each one equals the last `sequence_number` ([rules](../../guides/websocket.md#sequence-numbers-and-gaps)). On a gap, re-subscribe, then fetch current state over HTTP ([`transfer_history`](../rpc/transfer_history.md)) for what you missed. |
| Contract id | `transfer.transfer` (`StreamTransferV1`) |

## Selector

Grammar `<main_account_id>[-<sub_account_id>]`, e.g. `<main_account_id>-<sub_account_id>`. Parts:

- `main_account_id` · address — The main account ID to request for
- `sub_account_id` · uint64, optional — The sub-account ID to request for

## Frame

Type `WSTransferFeedDataV1`.

- `stream` · lite `s` · string · required — The stream this frame belongs to, e.g. `v1.transfer`.
- `selector` · lite `s1` · string · required — The selector this frame is for, as you subscribed with it.
- `sequence_number` · lite `sn` · string (uint64) · required — This frame's number, an unsigned 64-bit integer sent as a decimal string: compare it as an integer. `"0"` on the snapshot sent right after subscribing.
  - With `use_global_sequence_number: true` (recommended), the number is unique across the exchange. One exchange event can produce several frames, so the number is `event number × 10^5 + a counter` that tells them apart.
  - With `false`, it counts up by one per frame of this stream and starts again when the server you are connected to restarts.
- `feed` · lite `f` · object TransferHistory · required — The transfer history matching the requested filters
- `feed.tx_id` · lite `ti` · string (uint64) · required — The transaction ID of the transfer
- `feed.from_account_id` · lite `fa` · string (0x address) · required — The account to transfer from
- `feed.from_sub_account_id` · lite `fs` · string (uint64) · required — The sub-account to transfer from (0 if transferring from main account)
- `feed.to_account_id` · lite `ta` · string (0x address) · required — The account to deposit into
- `feed.to_sub_account_id` · lite `ts` · string (uint64) · required — The sub-account to transfer to (0 if transferring to main account)
- `feed.currency` · lite `c` · string · required — The token currency to transfer
- `feed.num_tokens` · lite `nt` · string · required — The number of tokens to transfer
- `feed.signature` · lite `s` · object Signature · required — The signature of the transfer
- `feed.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.
- `feed.signature.r` · lite `r` · string (uint256) · required — The signature's `r`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `feed.signature.s` · lite `s1` · string (uint256) · required — The signature's `s`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `feed.signature.v` · lite `v` · integer (uint8) · required — The signature's `v`, 27 or 28.
- `feed.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.
- `feed.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.
- `feed.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.
- `feed.event_time` · lite `et` · string (int64 unix ns) · required — The timestamp of the transfer in unix nanoseconds
- `feed.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)).
- `feed.transfer_metadata` · lite `tm` · string · required — The metadata of the transfer
- `feed.from_wallet_type` · lite `fw` · enum WalletType · required — The wallet type of the from account or sub-account
  Values: `FUNDING`, `SPOT`, `FUTURES` ([details](../enums.md#wallettype)).
- `feed.to_wallet_type` · lite `tw` · enum WalletType · required — The wallet type of the to account or sub-account
  Values: `FUNDING`, `SPOT`, `FUTURES` ([details](../enums.md#wallettype)).
- `prev_sequence_number` · lite `ps` · string (uint64) · required — The `sequence_number` of the frame before this one on this selector. If it doesn't match the last frame you accepted, you missed frames.

## Errors

Subscribe errors arrive as a JSON-RPC `error` object `{code, message}` (lite `{c, m}`). Codes this stream can return ([all error codes](../errors.md)):

`1001` Forbidden (403) · `1008` IPNotWhitelisted (401) · `1101` InvalidFeedFormat (400) · `1102` PrimarySelectorParts (400) · `1103` SecondarySelectorParts (400) · `3020` InvalidSubAccountID (400)

## Example

```python
import asyncio
import os

from grvt import AsyncGrvt


async def main():
    async with AsyncGrvt(env=os.environ.get("GRVT_ENV", "testnet"), api_key=os.environ["GRVT_API_KEY"]) as client:
        async with client.transfer_stream(main_account_id=os.environ["GRVT_MAIN_ACCOUNT_ID"]) as sub:
            async for frame in sub:
                print(frame.sequence_number, frame.feed)


asyncio.run(main())
```

Raw WebSocket: connect to `wss://trades.$GRVT_DOMAIN/ws/full` (`/ws/lite` for lite names) with the `Cookie: gravity=...` and `X-Grvt-Account-Id` headers and send:

With full field names:

```json
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "stream": "v1.transfer",
    "selectors": ["$GRVT_MAIN_ACCOUNT_ID"],
    "use_global_sequence_number": true
  },
  "id": 1
}
```

With lite field names:

```json
{
  "j": "2.0",
  "m": "subscribe",
  "p": {
    "s": "v1.transfer",
    "s1": ["$GRVT_MAIN_ACCOUNT_ID"],
    "ug": true
  },
  "i": 1
}
```

The reply's `result` is a `WSSubscribeResult` (`subs`, `num_snapshots`, `latest_sequence_number`); then frames arrive in the shape under Frame above, with no JSON-RPC envelope.
