MCPcopy Create free account
hub / github.com/ccxt/ccxt / withdraw

Method withdraw

python/ccxt/coinbase.py:3933–4025  ·  view source on GitHub ↗

make a withdrawal https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/send-crypto :param str code: unified currency code :param float amount: the amount to withdraw :param str address: the address to withdraw to :param str [tag]: an optional ta

(self, code: str, amount: float, address: str, tag: Str = None, params={})

Source from the content-addressed store, hash-verified

3931 return self.parse_tickers(tickers, symbols)
3932
3933 def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
3934 """
3935 make a withdrawal
3936
3937 https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/send-crypto
3938
3939 :param str code: unified currency code
3940 :param float amount: the amount to withdraw
3941 :param str address: the address to withdraw to
3942 :param str [tag]: an optional tag for the withdrawal
3943 :param dict [params]: extra parameters specific to the exchange API endpoint
3944 :param str [params.network]: the cryptocurrency network to use for the withdrawal using the lowercase name like bitcoin, ethereum, solana, etc.
3945 :param dict [params.travel_rule_data]: some regions require travel rule information for crypto withdrawals, see the exchange docs for details https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/travel-rule
3946 :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
3947 """
3948 tag, params = self.handle_withdraw_tag_and_params(tag, params)
3949 self.check_address(address)
3950 self.load_markets()
3951 currency = self.currency(code)
3952 request = {
3953 'type': 'send',
3954 'to': address,
3955 'amount': self.number_to_string(amount),
3956 'currency': currency['id'],
3957 }
3958 accountId = self.safe_string_2(params, 'account_id', 'accountId')
3959 params = self.omit(params, ['account_id', 'accountId'])
3960 if accountId is None:
3961 if code is None:
3962 raise ArgumentsRequired(self.id + ' withdraw() requires an account_id(or accountId) parameter OR a currency code argument')
3963 accountId = self.find_account_id(code, params)
3964 if accountId is None:
3965 raise ExchangeError(self.id + ' withdraw() could not find account id for ' + code)
3966 request['account_id'] = accountId
3967 else:
3968 request['account_id'] = accountId
3969 if tag is not None:
3970 request['destination_tag'] = tag
3971 response = self.v2PrivatePostAccountsAccountIdTransactions(self.extend(request, params))
3972 #
3973 # {
3974 # "data": {
3975 # "id": "a1794ecf-5693-55fa-70cf-ef731748ed82",
3976 # "type": "send",
3977 # "status": "pending",
3978 # "amount": {
3979 # "amount": "-14.008308",
3980 # "currency": "USDC"
3981 # },
3982 # "native_amount": {
3983 # "amount": "-18.74",
3984 # "currency": "CAD"
3985 # },
3986 # "description": null,
3987 # "created_at": "2024-01-12T01:27:31Z",
3988 # "updated_at": "2024-01-12T01:27:31Z",
3989 # "resource": "transaction",
3990 # "resource_path": "/v2/accounts/a34bgfad-ed67-538b-bffc-730c98c10da0/transactions/a1794ecf-5693-55fa-70cf-ef731748ed82",

Callers

nothing calls this directly

Calls 13

find_account_idMethod · 0.95
parse_transactionMethod · 0.95
ArgumentsRequiredClass · 0.90
ExchangeErrorClass · 0.90
check_addressMethod · 0.80
safe_string_2Method · 0.80
safe_dictMethod · 0.80
load_marketsMethod · 0.45
currencyMethod · 0.45
omitMethod · 0.45

Tested by

no test coverage detected