Developers

Withdrawal

Withdraw funds from Grvt to an Ethereum address.

On this page

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.

Bridging to Ethereum takes time. Unless you withdraw your whole balance there is a minimum amount (currently about 25 USDT), and a fee pays for the Ethereum transaction (get_withdrawal_fee). Your funds stay in self-custody throughout: Grvt never takes control of them.

SDKclient.withdrawal(...)
HTTPPOST https://trades.testnet.grvt.io/full/v1/withdrawal, or /lite/v1/withdrawal for lite names (the SDKs' default)
WebSocketmethod v1/withdrawal on wss://trades.testnet.grvt.io/ws/full, or /ws/lite for lite names
AuthSession required (Authentication)
Signedsignature is signed: Withdrawal / WithdrawalV2. Withdrawal when the currency id fits uint8 (<= 255), else WithdrawalV2. (Signing)
RetriesWrite: never retried automatically (why)
Contract idtransfer.withdrawal (RPCWithdrawalV1)

Request

Body type ApiWithdrawalRequest. Fields the server fills are left out.

  • from_account_idlite name fastring (0x address)required#
    The main account to withdraw from
  • to_eth_addresslite name testring (0x address)required#
    The Ethereum wallet to withdraw into
  • currencylite name cstringrequired#
    The token currency to withdraw
  • num_tokenslite name ntstringrequired#
    The number of tokens to withdraw. Decimal string, e.g. "1500.0"; up to the currency's balance_decimals. Scaled to an integer only inside the signature.
  • signaturelite name sobject Signaturerequired#
    The signature of the withdrawal
    7 fields of Signature
    • signerlite name sstring (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.
    • rlite name rstring (uint256)required#
      The signature's r, as 0x + 64 hex characters. Without the 0x the signature fails to verify.
    • slite name s1string (uint256)required#
      The signature's s, as 0x + 64 hex characters. Without the 0x the signature fails to verify.
    • vlite name vinteger (uint8)required#
      The signature's v, 27 or 28.
    • expirationlite name estring (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.
    • noncelite name ninteger (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.

    • chain_idlite name cistring (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.

Response

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

resultlite name robject Ackrequired#
The Ack Object
  • acklite name aboolrequired#
    True when the exchange received the request and will process it. It doesn't mean the request has taken effect yet.

Errors

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

4010WithdrawalWalletNotSupported400
This wallet is not supported. Please try another wallet.
4014CurrencyTransferNotAllowed400
This currency has been disabled for transfers and withdrawals.
4016TransferWithdrawalBlocked403
As a precaution, funds movements on your account are temporarily unavailable. Please contact support so we can help complete the necessary checks.
4019WithdrawalWalletUnderReview400
Your wallet has been put under review. Please reach out to [email protected] for any questions.
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, 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.withdrawal(
        from_account_id=os.environ["GRVT_MAIN_ACCOUNT_ID"],
        to_eth_address="0x1111111111111111111111111111111111111111",
        currency="USDT",
        num_tokens=Decimal("250.5"),
    )
    print(resp)

Raw HTTP (set GRVT_DOMAIN, see Environments; GRVT_COOKIE and GRVT_ACCOUNT_ID come from login):

The body below is the withdrawal 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/withdrawal" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "from_account_id": "0x0c3e7b0a6c8a1b2d3e4f5a6b7c8d9e0f1a2b3c4d",
  "to_eth_address": "0x1111111111111111111111111111111111111111",
  "currency": "USDT",
  "num_tokens": "250.5",
  "signature": {
    "signer": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
    "expiration": "4102444800000000000",
    "nonce": 3001,
    "chain_id": "326",
    "r": "0xc5ac8c71098de5015667d228e222ccec468f4d7f437686440a3b0551757c51ea",
    "s": "0x606969302f89ceae0819b04986e68cdb12c025aeca809b7f434691f54d1148c2",
    "v": 28
  }
}
EOF

With lite field names:

curl -sS "https://trades.testnet.grvt.io/lite/v1/withdrawal" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "fa": "0x0c3e7b0a6c8a1b2d3e4f5a6b7c8d9e0f1a2b3c4d",
  "te": "0x1111111111111111111111111111111111111111",
  "c": "USDT",
  "nt": "250.5",
  "s": {
    "s": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
    "e": "4102444800000000000",
    "n": 3001,
    "ci": "326",
    "r": "0xc5ac8c71098de5015667d228e222ccec468f4d7f437686440a3b0551757c51ea",
    "s1": "0x606969302f89ceae0819b04986e68cdb12c025aeca809b7f434691f54d1148c2",
    "v": 28
  }
}
EOF
Build & sign locally
esc

↑ ↓ move↵ open⇧↵ open .mdTry an error code like 2002

Keyboard shortcuts

⌘ K
Search the docs
/
Search
l
Next code language (Python → TypeScript → Go → Rust → curl → WebSocket)
j / k
Next / previous page
t
Light / dark theme
?
This help
Esc
Close dialogs and drawers