我想使用Python从Binance帐户vie API中获得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'))\结果:
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)**发布于 2022-05-18 18:20:03
我相信您可能不太明白python字典get()方法的作用。
根据W3schools,“get()方法使用指定的键返回项的值”。
client.get_deposit_address(tag='', coin='USDT')的输出没有一个名为TRC20的键,这就是get('TRC20')返回None的原因。如果使用get('url'),它将工作并返回一个值,因为字典中有一个名为url的键。
此外,为了检索TRC20存款地址而不是默认的ERC20地址,您需要指定一个额外的可选参数,该参数在Binance 文档中定义为network。
address = client.get_deposit_address(tag='', coin='USDT', network='TRX')
USDTron = address.get('address')网络名称在二进制存款地址网页上的下拉列表中找到。对于TRC20,这是TRX。

https://stackoverflow.com/questions/72293439
复制相似问题