查询币安智能链账户余额-解码bech32失败
Query account balance on Binance Smart Chain - decoding bech32 failed
我正在尝试通过币安链获取 public 地址的余额 API
account_id = "0x1f5ff990d661a4DFDC0Ff7D63Ae6A7E995475b95"
response = requests.get("https://dex.binance.org/api/v1/account/" + account_id.lower())
account = response.json()
但是我得到以下错误
{'code': 400, 'message': 'decoding bech32 failed: failed converting data to bytes: invalid character not part of charset: 98'}
如何将 public 地址转换为 bech32 格式?或者有没有更好的提取地址余额的方法?
终于发现不是你。它的 binance API 给了你那个错误。在做了一些挖掘之后,我发现出于某种原因,binance API 只采用带有 bnb:
标签的 Bech32 格式地址
import requests
account_id = "bnb1jxfh2g85q3v0tdq56fnevx6xcxtcnhtsmcu64m" # address 91937520f40458f5b414d267961b46c19789dd70
response = requests.get("https://dex.binance.org/api/v1/account/" + account_id.lower())
account = response.json()
print(account)
但是当你search/get一个地址时,它会以正常的 0x 格式给你
我确实在网上找到了一个能够将示例地址解码为正常的转换器:https://slowli.github.io/bech32-buffer/
但出于某种原因,API 仍然使用相同的转换器为您的地址报告 404:
import requests
account_id = "bnb1ra0lnyxkvxjdlhq07ltr4e48ax25wku4nhunzs" # address 1f5ff990d661a4DFDC0Ff7D63Ae6A7E995475b95
response = requests.get("https://dex.binance.org/api/v1/account/" + account_id.lower())
account = response.json()
print(account)
即使您使用完全相同的地址,您也可以使用智能链资源管理器查看它。 https://bscscan.com/address/0x1f5ff990d661a4DFDC0Ff7D63Ae6A7E995475b95
总之。这个问题的答案是您提供 API 的地址,而没有先将其转换为 Bech32 格式。现在你只需要弄清楚为什么即使地址转换为bech32它仍然是returns 404。可能需要向币安团队提出建议
我正在尝试通过币安链获取 public 地址的余额 API
account_id = "0x1f5ff990d661a4DFDC0Ff7D63Ae6A7E995475b95"
response = requests.get("https://dex.binance.org/api/v1/account/" + account_id.lower())
account = response.json()
但是我得到以下错误
{'code': 400, 'message': 'decoding bech32 failed: failed converting data to bytes: invalid character not part of charset: 98'}
如何将 public 地址转换为 bech32 格式?或者有没有更好的提取地址余额的方法?
终于发现不是你。它的 binance API 给了你那个错误。在做了一些挖掘之后,我发现出于某种原因,binance API 只采用带有 bnb:
标签的 Bech32 格式地址import requests
account_id = "bnb1jxfh2g85q3v0tdq56fnevx6xcxtcnhtsmcu64m" # address 91937520f40458f5b414d267961b46c19789dd70
response = requests.get("https://dex.binance.org/api/v1/account/" + account_id.lower())
account = response.json()
print(account)
但是当你search/get一个地址时,它会以正常的 0x 格式给你
我确实在网上找到了一个能够将示例地址解码为正常的转换器:https://slowli.github.io/bech32-buffer/
但出于某种原因,API 仍然使用相同的转换器为您的地址报告 404:
import requests
account_id = "bnb1ra0lnyxkvxjdlhq07ltr4e48ax25wku4nhunzs" # address 1f5ff990d661a4DFDC0Ff7D63Ae6A7E995475b95
response = requests.get("https://dex.binance.org/api/v1/account/" + account_id.lower())
account = response.json()
print(account)
即使您使用完全相同的地址,您也可以使用智能链资源管理器查看它。 https://bscscan.com/address/0x1f5ff990d661a4DFDC0Ff7D63Ae6A7E995475b95
总之。这个问题的答案是您提供 API 的地址,而没有先将其转换为 Bech32 格式。现在你只需要弄清楚为什么即使地址转换为bech32它仍然是returns 404。可能需要向币安团队提出建议