如何检查Python中USDT(系绳)的余额?

发布于 2025-01-30 17:21:13 字数 818 浏览 6 评论 0原文

我最近正在研究我的Python加密项目,但是我必须制作一种检查绳索钱包平衡的方法。有没有办法检查与Python的系绳的平衡? 这是我的代码:

class wallet_Tether:
#Tether shares same blockchain with bitcoin

def __init__(self,wallet_address,wallet_privatekey,wallet_balance,wallet_history,wallet_public_key,wallet_name,wallet):

    self.wallet_address = wallet_address
    self.wallet_privatekey = wallet_privatekey
    self.wallet_balance = wallet_balance
    self.wallet_history = wallet_history
    self.wallet_public_key = wallet_public_key
    self.wallet_name = wallet_name
    self.wallet = wallet

def create_address(self):

    self.wallet = Wallet.create(self.wallet_name)
    key_usdt = self.wallet.get_key()
    self.wallet_address = key_usdt.get_address

    return self.wallet_address

def check_balance(self):

    return self.wallet_balance

I was working on my python crypto project recently, but I had to make a method that checks balance of Tether wallet. Is there a way to check balance of tether with python?
this is my code:

class wallet_Tether:
#Tether shares same blockchain with bitcoin

def __init__(self,wallet_address,wallet_privatekey,wallet_balance,wallet_history,wallet_public_key,wallet_name,wallet):

    self.wallet_address = wallet_address
    self.wallet_privatekey = wallet_privatekey
    self.wallet_balance = wallet_balance
    self.wallet_history = wallet_history
    self.wallet_public_key = wallet_public_key
    self.wallet_name = wallet_name
    self.wallet = wallet

def create_address(self):

    self.wallet = Wallet.create(self.wallet_name)
    key_usdt = self.wallet.get_key()
    self.wallet_address = key_usdt.get_address

    return self.wallet_address

def check_balance(self):

    return self.wallet_balance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡的优雅 2025-02-06 17:21:13

Explorer API获取平衡信息。

您可以使用Tether

它允许您每天免费发送100,000个请求,每秒免费发送5个请求。

https://docs.etherscan.io/getting started-started-started/creating-creating-an--an---an---an---an---an---an--an---帐户 - >某些API DOC

import requests

url = "https://api.etherscan.io/api"
address = "Your address"
apikey = "Your apikey"
params = {"module": "account", "action": "balance", "address": address, "tag": "latest", "apikey": apikey}
response = requests.get(url, params=params).json()

变量响应包含带有平衡数据的字典。
示例:

{
   "status":"1",
   "message":"OK",
   "result":"40891626854930000000000" 
}

结果在WEI中返回。因此,我们需要将结果除以10^18的

total_balance = int(response["result"]) / (10**18)

总计balance -tether Wallet Balance

You can use tether explorer api to get balance information.

For example, etherscan.io api ->

It allows you to send 100,000 requests per day and 5 requests per second for free.

https://docs.etherscan.io/getting-started/creating-an-account -> Some api docs

import requests

url = "https://api.etherscan.io/api"
address = "Your address"
apikey = "Your apikey"
params = {"module": "account", "action": "balance", "address": address, "tag": "latest", "apikey": apikey}
response = requests.get(url, params=params).json()

Variable response contains a dictionary with balance data.
Example:

{
   "status":"1",
   "message":"OK",
   "result":"40891626854930000000000" 
}

The result is returned in wei. So, we need to divide result by 10^18

total_balance = int(response["result"]) / (10**18)

Where total_balance - your tether wallet balance

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文