Transfer
Move funds between your main account and its sub-accounts, or to an allowlisted main account.
On this page
Write a small program that calls `transfer.transfer` on Grvt {environment} {using}.
Target environment: {environment} (chain ID {chainId}). Recorded signing cases keep their original environment.
{executionGuidance}
Read this first: {origin}/bundle/reference/rpc/transfer.md (~80 KB, plain Markdown: this page plus the AGENTS.md rules, Authentication and sessions, Signing, Transfer (signed message), TransferV2 (signed message), TransferV3 (signed message), Errors and retries, Python SDK, Environments).
Fetch other pages from the index at {origin}/llms.txt only as you need them. {origin}/downloads/contract.json is a machine-readable contract for tools, not for reading.
Rules: follow AGENTS.md; do not send requests without the user asking you to; read credentials from environment variables; never retry writes automatically; show me the code and how to run it. URLs and generated code samples on this page: Testnet (chain ID 326). Other code on this page doesn't change: it stays on testnet until you switch it in your code. Tutorials, signing cases and live tools always use testnet.
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.
| SDK | client. |
|---|---|
| HTTP | POST https:/, or /lite/v1/transfer for lite names (the SDKs' default) |
| WebSocket | method v1/transfer on wss:/, or /ws/lite for lite names |
| Auth | Session required (Authentication) |
| Signed | signature is signed: Transfer / TransferV2 / TransferV3. 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) |
| Retries | Write: never retried automatically (why) |
| Contract id | transfer.transfer (RPCTransferV1) |
Request
Body type ApiTransferRequest. Fields the server fills are left out.
- The main account to transfer from
- The sub-account to transfer from (0 if transferring from main account)
- The main account to deposit into
- The sub-account to transfer to (0 if transferring to main account)
- The token currency to transfer
- 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.
- The signature of the transfer
7 fields of
Signature- 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. - The signature's
r, as0x+ 64 hex characters. Without the0xthe signature fails to verify. - The signature's
s, as0x+ 64 hex characters. Without the0xthe signature fails to verify. - The signature's
v, 27 or 28. - 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 reasonEXPIRED. The SDKs use now + 24 hours. - 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_CANCELorder 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. - The chain id in the signed EIP-712 domain, as a string. Testnet 326, production 325;
"0"means the environment's chain id.
- The type of transfer
12 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). - The metadata of the transfer
- The wallet type of the from account or sub-account
3 values
- The wallet type of the to account or sub-account
3 values
Response
Body type ApiTransferResponse (the same object is the JSON-RPC result over WebSocket).
- True when the exchange has processed the transfer. If true, a
tx_idwill be returned. If false, an error will be returned. - 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 (all error codes):
4000InsufficientBalanceToTransfer400- Insufficient balance to complete transfer
4002TransferFailedReasonUnrefined400- Transfer failed with an unrefined failure reason, please report to GRVT
4004BothTransferWalletTypeMustBeProvided400- Both transfer wallet types must be provided
4005InvalidWalletTypeForFundingAccount400- Invalid wallet type for funding account
4006InvalidWalletTypeForSubAccount400- Invalid wallet type for sub account
4007DuplicatedTransfer400- Transfer failed because signature is an exact duplicate of another recently-observed transfer.
4008CurrencyNotAllowedInWallet400- Currency is not allowed in the target wallet type
4009UnspecifiedTransferType400- Please specify the transfer type
4010WithdrawalWalletNotSupported400- This wallet is not supported. Please try another wallet.
4011CVRZeroNotAllowedInFuturesWallet400- This currency cannot be used as collateral in a multi-asset margin futures wallet.
Show 21 more errors for this call
4012CollateralLimitExceeded400- Transfer would push your holdings of this currency above the per-user collateral limit.
4014CurrencyTransferNotAllowed400- This currency has been disabled for transfers and withdrawals.
4015NoTransferPermission403- Signer does not have transfer permission
4016TransferWithdrawalBlocked403- As a precaution, funds movements on your account are temporarily unavailable. Please contact support so we can help complete the necessary checks.
4018GrvtExternalTransferNotAllowed400- $GRVT is disabled for external transfer
4019WithdrawalWalletUnderReview400- Your wallet has been put under review. Please reach out to [email protected] for any questions.
4020CurrencyNotEnabledAsCollateral400- This currency is not enabled as collateral for the destination sub account. Enable it in your collateral preferences first.
4021InsufficientFundingVaultShares400- The funding account has fewer vault shares than requested, after reserving any pending redemption.
4022InsufficientTradingVaultShares400- The trading account has fewer vault shares than requested.
4023VaultShareTransferRoute400- Vault shares move only between your own funding account and your own multi-asset trading accounts.
5000InvalidTransferMetadata400- Transfer Metadata does not match the expected structure.
5001InvalidTransferProvider400- Transfer Provider does not match the expected provider.
5002InvalidDirection400- Direction of the transfer does not match the expected direction.
5003InvalidEndpoint400- Endpoint account ID is invalid.
5004FundingAccountDoesntExist400- Funding account does not exist in our system.
5005InvalidChainID400- Invalid ChainID for the transfer request.
7100UnknownTransactionType500- Unknown transaction type
7101TransferAccountNotFound400- Transfer account not found
7102TransferSubAccountNotFound400- Transfer sub-account not found
7103ChargedTradingFeeBelowConfigMinimum500- Charged trading fee below the config minimum
7104TransferSubAccountNotUnderAccount400- Transfer sub-account doesn't belong to the transfer main account
Plus 8 errors any call can return
1000Unauthorized401- You need to authenticate prior to using this functionality
1001Forbidden403- You are not authorized to access this functionality
1002InternalServer500- Internal Server Error
1003InvalidRequest400- Request could not be processed due to malformed syntax
1006RateLimit429retryable- You have surpassed the allocated rate limit for your tier
1008IPNotWhitelisted401- Your IP has not been whitelisted for access
1014GatewayTimeout504retryable- Upstream data service timed out, please try again
1015ServiceUnavailable503retryable- Upstream data service is temporarily unavailable, please try again
Example
Example code
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; GRVT_COOKIE and GRVT_ACCOUNT_ID come from login):
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; 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:
curl -sS "https://trades.testnet.grvt.io/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"
}
EOFWith lite field names:
curl -sS "https://trades.testnet.grvt.io/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