Skip to content

Instantly share code, notes, and snippets.

@rhettre
Created July 28, 2022 03:12
Embed
What would you like to do?
Coinbase Pro Withdrawal Crypto
import cbpro
import json
from math import floor
my_key = ""
my_secret = ""
my_passphrase = ""
my_currency = "BTC"
withdraw_address = ""
withdraw_precision = 8
def _withdrawCrypto(cb_key, cb_secret, cb_passphrase):
auth_client = cbpro.AuthenticatedClient(cb_key, cb_secret, cb_passphrase)
for account in auth_client.get_accounts():
if account['currency'] == my_currency:
withdraw_size = (floor(float(account['available'])*(10**(withdraw_precision))))/(10**(withdraw_precision))
print(account)
print(f"Withdraw size = {withdraw_size}")
withdrawal = auth_client.crypto_withdraw(withdraw_size, my_currency, withdraw_address)
print(withdrawal)
return withdraw_size
def lambda_handler(event, context):
withdrawal = _withdrawCrypto(my_key,my_secret,my_passphrase)
return {
'statusCode': 200,
'body': json.dumps(f"You withdrew {my_currency}!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment