Skip to content

Instantly share code, notes, and snippets.

@rhettre
Created July 28, 2022 13:41
Show Gist options
  • Save rhettre/b4cc15f149572278e629c95e731d8492 to your computer and use it in GitHub Desktop.
Save rhettre/b4cc15f149572278e629c95e731d8492 to your computer and use it in GitHub Desktop.
FTX Withdrawals
import ftx
import json
import random
YOUR_API_KEY = ""
YOUR_API_SECRET = ""
#Fill in your FTX API Keys above
coin = 'BTC'
#change COIN to 'ETH' for Ethereum, 'ADA' for Cardano (etc)
size = 0.01
#Change size to crypto amount you want to withdrawal
withdrawAllAvailable = True
#Set withdrawAllAvailable to True to override the size and withdraw everything. Set to False to use the size variable
btcAddress1 = ""
withdrawal_addresses = [btcAddress1]
#add one address to always withdraw to that single address: ["btcaddress1"]
#add multiples to randomly withdraw to one of many addresses (better privacy): ["btcaddress1","btcaddress2","btcaddress3"]
address = random.choice(withdrawal_addresses)
tag = None
method = None
#Method optional; blockchain to use for withdrawal see documentation
password = None
#Password optional; withdrawal password if it is required for your account
code = None
#Code optional; 2fa code if it is required for your account you would need to integrate with Authy/Google Authenticator for this to work
client = ftx.FtxClient(api_key=YOUR_API_KEY, api_secret=YOUR_API_SECRET)
#EX: coin = 'BTC' or coin = 'USD' or coin = 'ETH'
def getCoinAvailableForWithdrawalBalance(coin):
balances = client.get_balances()
availableForWithdrawal = list(filter(lambda balance: balance['coin'] == coin,balances))[0]['availableForWithdrawal']
print(availableForWithdrawal)
return availableForWithdrawal
def withdrawCoin():
if(withdrawAllAvailable):
size = getCoinAvailableForWithdrawalBalance(coin)
withdrawal = client.request_withdrawal(coin, size, address, tag, method, password, code)
print(withdrawal)
def lambda_handler(event, context):
withdrawCoin()
return {
'statusCode': 200,
'body': json.dumps('Withdrawal sent!')
}
@rhettre
Copy link
Author

rhettre commented Jul 28, 2022

FTX Withdrawal Documentation: https://docs.ftx.com/#request-withdrawal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment