- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 Web3 开发确实很陌生,想知道是否有一种方法可以从智能合约中找到的代币地址获取有关代币的更多信息(即我有一个代币地址,但不知道是什么类型的代币)直到我在 etherscan 上查找交易哈希)。我可以直接从区 block 链/Web3 模块中提取这些信息,还是需要使用外部 API 来收集这些信息?
最佳答案
您可以使用web3py直接获取 token 详细信息
这是获取 token 名称的简单示例(在本例中为 Strong)
import json
from web3 import Web3
# Fill in your infura API key here
infura_url = "https://mainnet.infura.io/v3/YOUR_INFURA_API_KEY_GOES_HERE"
web3 = Web3(Web3.HTTPProvider(infura_url))
# Get it from Etherscan and change true => True and false => False
abi = [{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":False,"inputs":[{"indexed":True,"internalType":"address","name":"owner","type":"address"},{"indexed":True,"internalType":"address","name":"spender","type":"address"},{"indexed":False,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":False,"inputs":[{"indexed":True,"internalType":"address","name":"from","type":"address"},{"indexed":True,"internalType":"address","name":"to","type":"address"},{"indexed":False,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
address = '0x990f341946A3fdB507aE7e52d17851B87168017c'
contract = web3.eth.contract(address=address, abi=abi)
# Let's print Name of Token
print(contract.functions.name().call())
关于python - 从 ERC-20 代币地址获取有关代币的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69858039/
我是 solidity 和 erc20 的新手,所以我阅读了关于 openzeppelin 的 ERC20 描述。并找到这个我不清楚的功能。 approve(spender, amount) 允许sp
我正在使用下面的 elisp 代码来修改来自 ERC 的传入消息 (defun my-modify (msg) (replace-regexp-in-string "abc" "xyz" msg)
抽象账户是什么 抽象账户(也有叫合约钱包)是 EIP-4337 提案提出的一个标准。简单来说就是通过智能合约来实现一个“账户(account)”,在合约中自行实现签名验证的逻辑。这样,就使得该
有没有办法让 ERC 突出显示与某个正则表达式匹配的所有行?就上下文而言,我正在使用 ERC 连接到 bitlbee 服务器,并希望当我发出“blist”命令时,在线的 friend 以绿色突出显示,
有人能告诉我从以太坊区 block 链获取 ERC-20 代币信息(小数位数、名称和符号)的正确方法吗? 我认为可以通过 ABI 构造(如果用户 web3js 库)调用适当的函数 decimals()
我对 Web3 开发确实很陌生,想知道是否有一种方法可以从智能合约中找到的代币地址获取有关代币的更多信息(即我有一个代币地址,但不知道是什么类型的代币)直到我在 etherscan 上查找交易哈希)。
我对 Web3 开发确实很陌生,想知道是否有一种方法可以从智能合约中找到的代币地址获取有关代币的更多信息(即我有一个代币地址,但不知道是什么类型的代币)直到我在 etherscan 上查找交易哈希)。
Emacs erc 保持重新居中。因此很难跟上小缓冲区中的对话。 我尝试了以下方法,但似乎都不起作用... (erc-scrolltobottom-mode) (require 'erc-goodie
我正在开发一个智能合约 (SC) 和一个前端 Dapp,用于销售一些 NFT ERC-721 代币。当用户/地址购买其中一个 NFT 代币时,该代币将由 SC 为他的利益类型转换,而我的 Dapp 将
我有一份 ERC721 合约,我有一个问题,我正在尝试以另一种货币设置价格,例如 UNI 或 SUSHI但问题是我不知道如何更改它,我对契约(Contract)了解不多,这是代码。 我想知道是否有可能
我有一份来自 Hash Lip 的 github 的智能合约,据我所知应该一次类型转换 1 个,但每次都类型转换 2 个。代码如下: 设置代码: // SPDX-License-Identifier:
如果有人为 eth 出售或购买我们的代币(例如,我的意思是 uniswap),有没有办法检查 erc-20 代币的 transfer() 方向? 最佳答案 Uniswap 交易是掉期,而不是买卖。它可
我需要一个功能的帮助,一旦他的内容(Ipfs-Hash,见下面的程序)达到 n 个喜欢(假设每 100 个喜欢),就用 erc777-token 奖励用户,即每当 ' netLike' 计数器达到 1
The ERC Manual显示加载身份验证信息的代码: (加载“~/.emacs.d/.erc-auth”) 但没有显示身份验证信息的样子。我希望有一个示例文件。 最佳答案 它没有任何特定的格式。它
我最近一直在尝试学习有关智能合约的知识,但是当我试图了解代币转移的工作原理时,我遇到了这个问题。 ||执行恢复:ERC20:从零地址转账|| (ropsten 网络) 代码: import (
我正在寻找一种方法来获取 token 的买卖税,并检查它是否可以在购买后出售。 为此,这是我想到的方法: 1-在 DEX 路由器合约上模拟购买交易 2-在 DEX 路由器合约上模拟卖出交易 3-如果上
我正在尝试对我现有的 Rails 应用程序进行 docker 化。我使用 credentials.yml 已经有一段时间了。我的 credentials.yml 文件看起来像这样: productio
我是一名优秀的程序员,十分优秀!