简体   繁体   English

如何使用 Python 从我的 Binance 帐户 vie API 获取我的 Tron(TRC20)地址

[英]How can I get my Tron(TRC20) Address from my Binance Account vie API using Python

I wanted to get my Tron(TRC20) Address from my Binance Account vie API using Python, but all i got was my (Eth) Network Address.我想从我的 Binance 帐户 vie API 使用 Python 获取我的 Tron(TRC20)地址,但我得到的只是我的(Eth)网络地址。

**This is my code below.**
rom lib2to3.pygram import Symbols
import os
import config, csv
#and then import it in your python file with
from binance.client import Client
client = Client(config.api_key, config.api_secret)

address = client.get_deposit_address(tag='', coin='USDT')\
USDTron = (address.get('TRC20'))\

Results:结果:

print(address)
Output: {'coin': 'USDT', 'address': '0x1892e6d25a9d91dea9f9caac549261e601af97f8', 'tag': '', 'url': 'https://etherscan.io/address/0x1892e6d25a9d91dea9f9caac549261e601af97f8'}
***(I got my Eth Network Address as the output)***

print(USDTron)
Output: None
**The output was (None)**

I believe you might not quite understand what the python dictionary get() method does.我相信你可能不太明白 python 字典get()方法的作用。

According to W3schools "The get() method returns the value of the item with the specified key."根据W3schools ,“get() 方法返回具有指定键的项目的值。”

The output from client.get_deposit_address(tag='', coin='USDT') doesnt have a key called TRC20 which is why get('TRC20') is returning None .来自client.get_deposit_address(tag='', coin='USDT') USDT') 的 output 没有名为 TRC20 的密钥,这就是get('TRC20')返回None的原因。 If you used get('url') it would work and return a value since there is a key called url in the dictionary.如果您使用get('url')它会起作用并返回一个值,因为字典中有一个名为url的键。

Furthermore, in order to retrieve the TRC20 deposit address instead of the default ERC20 address, you need to specify an additional optional parameter which is called network as defined in the Binance API docs :此外,为了检索 TRC20 存款地址而不是默认的 ERC20 地址,您需要指定一个额外的可选参数,该参数称为 Binance API 文档中定义的network

address = client.get_deposit_address(tag='', coin='USDT', network='TRX')
USDTron = address.get('address')

The.network name is found in the dropdown on the binance deposit address webpage. .network 名称可在币安存款地址网页的下拉列表中找到。 For TRC20 it's TRX.对于 TRC20,它是 TRX。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何查询给定TRX地址的TRC20代币余额? - How to query the balance of a TRC20 token for a given TRX address? 如何使用 tronpy 转移 TRC20 代币? - How to transfer TRC20 token using tronpy? 为什么我无法获取我的帐户信息 binance api - Why can't I get my account info binance api 如何在Python使用API Binance获取账户信息 - How to get account information via using API Binance in Python 如何使用 Python 在 Binance API 中仅获取符号的图形 - How can I get only the figure of a symbol in Binance API using Python Binance API:如何使用python在binance中获取订单ID - Binance API: How to get an Order ID in binance using python 如何从Python管理我的Instagram帐户? - How can I manage my Instagram account from Python? python:使用 get_account() 的币安错误 - python: Binance error of using get_account() 如何使用“获取历史 Kline/Candlesticks”function 从 python-binance 获得最后一个说 20 个“收盘价”值? - How do you get the last say 20 "Close price" values from python-binance using the "Get Historical Kline/Candlesticks" function? 如何使用python从NAT内部网络获取我的公共IPV4地址 - How can I get my public IPV4 address from NAT internal network with python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM