Python Binance提现失败:APIError(code=-1102):非法参数

brccelvz  于 2023-05-30  发布在  Python
关注(0)|答案(1)|浏览(143)

我一直在浏览文档,但我看不到我错过了什么。该API已启用所有权限,包括IP限制,我相信我在请求中发送了正确的信息,但仍然失败...任何帮助都很感激。
('walletType':0是我的现货钱包)

from credentials import binance_api_key, binance_api_secret
from config_settings import get_api_key_permissions
from binance.client import Client
from binance.exceptions import BinanceAPIException
import requests
import time

binance_api_key_description, apiSpotMargin, apiFutures, apiWithdraw = get_api_key_permissions(binance_api_key, binance_api_secret)
print(binance_api_key_description)

client = Client(binance_api_key, binance_api_secret)

def withdraw_USDT_to(destination, amount):
    try:
        # Generate timestamp
        timestamp = int(time.time() * 1000)

        # Withdraw API call
        withdraw_params = {
            'asset': 'USDT',
            'address': destination,
            'amount': amount,
            'network': 'ERC20',
            'walletType': 0,
            'timestamp': timestamp
        }

        # Withdraw API call using the client
        withdraw_result = client.withdraw(**withdraw_params)

        print(withdraw_result)
    except BinanceAPIException as e:
        print(f"Withdrawal failed: {e}")

seb_usdt_erc20 = "0x47cd5f5b58333e1e8dac19ea76a9ee15903417b4"
withdraw_USDT_to(seb_usdt_erc20, 1)

我的输出是:

🔑 API Key: H9************************************************************7k
🔒 API Secret: Kh************************************************************17
🗓 API Created: 2023-05-22 14:04:17 (UTC)
🔏 IP Address Restricted: True
📄 Bot can read: True
📉 Bot can trade on Spot & Margin: True
📈 Bot can trade on Futures: True
🔃 Bot can make universal transfer: False
📤 Bot can withdraw money: True
Withdrawal failed: APIError(code=-1102): illegal parameter

Process finished with exit code 0
vxbzzdmp

vxbzzdmp1#

我在@halfelf的帮助下解决了这个问题,最终的工作代码看起来像这样

def withdraw_USDT_to(destination, amount):
    try:
        # Generate timestamp
        timestamp = int(time.time() * 1000)

        # Withdraw API call
        withdraw_params = {
            'coin': 'USDT',
            'address': destination,
            'amount': amount,
            'transactionFeeFlag': True
        }

        # Withdraw API call using the client
        withdraw_result = client.withdraw(**withdraw_params)
        # withdraw_result = client.withdraw(coin='USDT', address=destination, amount=amount, transactionFeeFlag=True)

        print(withdraw_result)
    except BinanceAPIException as e:
        print(f"Withdrawal failed: {e}")

相关问题