标签: etherscan

插件@nomiclabs/hardhat-etherscan 中出现错误:合约验证失败。原因:失败 - 无法验证 - 带参数

我试图用参数验证我的合同,但收到此错误:

Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed.
Reason: Fail - Unable to verify

Run Code Online (Sandbox Code Playgroud)

我还导入Open Zeppelin合同ERC721EnumerableOwnable.

这是我的NFTCollectible.sol


pragma solidity 0.8.10;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "hardhat/console.sol";

contract NFTCollectible is ERC721Enumerable, Ownable {
    using Strings for uint256;

    string public baseURI;
    string public baseExtension = ".json";
    uint256 public cost = 0.08 ether;
    uint256 public maxSupply = 5000;
    uint256 public maxMintAmount = 25;
    mapping(address => uint256) public addressMintedBalance;

    constructor(
        string memory _name,
        string memory _symbol, …
Run Code Online (Sandbox Code Playgroud)

solidity openzeppelin etherscan ethers.js hardhat

11
推荐指数
2
解决办法
2万
查看次数

错误:在调用多重调用合约以太坊的聚合函数时发送交易需要签名者

\n

index.js:1 无法获取多重调用块 [{\xe2\x80\xa6}] 1 错误:发送交易需要签名者(操作=“sendTransaction”,代码=UNSUPPORTED_OPERATION,版本=contracts/5.0.2)

\n
\n

多重调用合约地址 - https://etherscan.io/address/0xeefba1e63905ef1d7acba5a8513c70307c1ce441#writeContract

\n

在 Uniswap 界面中工作,但在我的代码中抛出错误,我不知道出了什么问题

\n

javascript reactjs ethereum ether etherscan

9
推荐指数
2
解决办法
2万
查看次数

使用导入的 OpenZeppelin 文件在 Etherscan 上验证并发布合约

我目前正在构建符合 ERC721 标准的合约,并已在此处发布合约: https: //ropsten.etherscan.io/address/0xa513bc0a0d3af384fefcd8bbc1cc0c9763307c39 - 我现在正在尝试验证并发布合约源代码

我的文件的开头如下所示:

// SPDX-License-Identifier: MIT

// We will be using Solidity version 0.8.4
pragma solidity 0.8.4;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract ViperToken is ERC721 {
Run Code Online (Sandbox Code Playgroud)

但是,当尝试使用 Solidity 单个文件进行验证和发布时,出现以下错误:

ParserError: Source "@openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File import callback not supported
 --> myc:6:1:
  |
6 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)

任何人都可以向我指出 1. 解决此问题或 2. 有关如何正确编写导入了可以使用 Etherscan 验证的依赖项的合约的文档。现在这只是一个单文件合同。

ethereum solidity smartcontracts cryptocurrency etherscan

9
推荐指数
2
解决办法
7258
查看次数

如何使用 ethers.utils.defaultAbiCoder 解码交易输入数据

我正在使用 Etherscan API 获取交易数据。这是我得到的示例结果:

{
  blockNumber: '7409930',
  timeStamp: '1639151980',
  hash: '...',
  nonce: '4124',
  ...
  input: '0x9d90e4c8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000093238bb66b5d15b4152c5db574e3397ff1b1a450',
  contractAddress: '',
  cumulativeGasUsed: '403775',
  gasUsed: '1162315',
  confirmations: '191308'
}
Run Code Online (Sandbox Code Playgroud)

我现在需要找出该交易的事件类型(合约方法,例如,,...)TransferOwnershipstakeTokens该数据存储在input该对象的属性中。

我设法使用abi-decoder库来完成此任务,但我想使用 ethers 的实用方法(以哪种方式)来完成同样的事情。

我当前的实现:

const abiDecoder = require("abi-decoder");
abiDecoder.addABI(contractAbi);
// "item" is transaction data, input property is encoded stuff from which I want to get the contract method used by this transaction
const decodedInput = abiDecoder.decodeMethod(item.input);

// contract method
console.log(decodedInput.name);
Run Code Online (Sandbox Code Playgroud)

我正在阅读以太坊的文档(https://docs.ethers.io/v5/api/utils/abi/coder/),但我无法弄清楚。

javascript ethereum web3js etherscan ethers.js

5
推荐指数
1
解决办法
4220
查看次数

如何在 etherscan (tuple[]) 上传递结构数组作为参数?

我试图将结构数组的格式作为 etherscan 上智能合约写入函数的参数传递,

这是坚固性示例:

Info[] 公共信息;

struct Info { 
    address userAddress;
    uint256 amount;   
    bool active; 
} 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 JavaScript 示例:

const data = [{0x0000, 10000000000, false},{0x11111, 20000000000, true}]
Run Code Online (Sandbox Code Playgroud)

任何人都可以将此数据示例转换为 tuple[] 并提供吗?提前致谢

javascript ethereum solidity etherscan

5
推荐指数
1
解决办法
7419
查看次数

etherscan-api 不输出待处理交易

我在这里使用 etherscan-api:(https://sebs.github.io/etherscan-api/#txlist)来获取用户的交易列表(给定公钥),并且我正在获取已清除的列表仅交易,即使在 etherscan.io 上我也可以看到所有待处理的交易,因此信息“在那里”。深入研究源代码https://github.com/sebs/etherscan-api/blob/master/lib/account.js#L122,我发现没有任何迹象表明我可以在哪里找到待处理的交易。代码如下:

const etherscan = require('etherscan-api').init(ETHERSCAN_TOKEN, 'ropsten', '3000');

    etherscan.account
        .txlist(public_key, 1, 'latest', 1, 100, 'asc')
        .then(res => {
            console.log("tx_list: ", res.result)
        })


    // get num of transactions
    etherscan.proxy
        .eth_getTransactionCount(public_key, 'latest')
        .then(res => {
            let count = res.result
            console.log("eth_getTransactionCount: ", parseInt(count))
        })
Run Code Online (Sandbox Code Playgroud)

javascript ethereum web3js metamask etherscan

4
推荐指数
1
解决办法
3234
查看次数

为什么从 ethers.js 获取的区块时间戳不等于 etherscan.io 中显示的时间戳?

import {providers} from "ethers";

const provider = new providers.InfuraProvider("homestead")

async function main() {
    provider.on("block", (blockNum)=> {
        console.log(blockNum+ ": " +new Date(Date.now()))
    })
}

main()
Run Code Online (Sandbox Code Playgroud)

从上面的代码输出:

13261128: Mon Sep 20 2021 14:57:42 GMT+0800 
13261129: Mon Sep 20 2021 14:58:14 GMT+0800 
13261130: Mon Sep 20 2021 14:58:42 GMT+0800 
13261131: Mon Sep 20 2021 14:58:58 GMT+0800 
Run Code Online (Sandbox Code Playgroud)

来自 etherscan.io:

Sep-20-2021 06:57:12 AM +UTC (https://etherscan.io/block/13261028)
Sep-20-2021 06:57:23 AM +UTC (https://etherscan.io/block/13261129)
Sep-20-2021 06:58:07 AM +UTC (https://etherscan.io/block/13261130)
Sep-20-2021 06:58:38 AM +UTC (https://etherscan.io/block/13261131)
Run Code Online (Sandbox Code Playgroud)

我的问题

  1. 我的电脑的时钟是准确的时间,为什么这两种方式有差异?

  2. 我可以从 ethers.js API …

ethereum etherscan ethers.js

4
推荐指数
1
解决办法
2万
查看次数

ERC20 代币从交易哈希传输信息

EtherScan 提供了一个用于交易细节的 API,它是 Geth/Parity 代理 API 的一部分,名称为 eth_getTransactionByHash,但我无法获得 ERC20 令牌被转移的信息以及转移了多少。

我需要在交易哈希的帮助下传输的令牌详细信息和令牌数量。
在此处输入图片说明

php ethereum web3js erc20 etherscan

2
推荐指数
1
解决办法
4488
查看次数

如何构建 Etherscan 网络爬虫?

我正在构建一个网络爬虫,每 30 秒不断刷新一些 etherscan URL,如果发生了任何未考虑到的新传输,它会向我发送一封电子邮件通知和一个指向 etherscan 上相关地址的链接,以便我可以手动检查他们出去。

我想要密切关注的地址之一在这里:

https://etherscan.io/token/0xd6a55c63865affd67e2fb9f284f87b7a9e5ff3bd?a=0xd071f6e384cf271282fc37eb40456332307bb8af

到目前为止我所做的:

from urllib.request import Request, urlopen
url = 'https://etherscan.io/token/0xd6a55c63865affd67e2fb9f284f87b7a9e5ff3bd?a=0x94f52b6520804eced0accad7ccb93c73523af089'
req = Request(url, headers={'User-Agent': 'XYZ/3.0'})   # I got this line from another post since "uClient = uReq(URL)" and "page_html = uClient.read()" would not work (I beleive that etherscan is attemption to block webscraping or something?)
response = urlopen(req, timeout=20).read()
response_close = urlopen(req, timeout=20).close()
page_soup = soup(response, "html.parser")
Transfers_info_table_1 = page_soup.find("div", {"class": "table-responsive"})
print(Transfers_info_table_1)
Run Code Online (Sandbox Code Playgroud)

有趣的是,当我运行它时,我得到以下输出:

<div class="table-responsive" style="visibility:hidden;">
<iframe frameborder="0" id="tokentxnsiframe" scrolling="no" src="" …
Run Code Online (Sandbox Code Playgroud)

beautifulsoup web-crawler web-scraping python-3.x etherscan

2
推荐指数
1
解决办法
4466
查看次数

如何使用 UniswapV2Router02 合约通过 swapExactTokensForETH() 将代币交换为 ETH

我打算使用 Etherscan(Ropsten 测试网络)上的 UniswapV2Router02 在 Ropsten 网络上将一些 DAI 兑换为 ETH。

Ropsten 上的 DAI 地址 = 0xad6d458402f60fd3bd25163575031acdce07538d WETH = 0xc778417E063141139Fce010982780140Aa0cD5Ab

我的钱包里有 2000 DAI (Ropsten)

但是当我把数据放在那里时。像这样: 在此输入图像描述

Metamask 显示合约抛出了一个错误。所以我可能错过了一些东西或者我做错了。

在此输入图像描述

请有人帮助并告诉我如何才能在那里成功交易?

ethereum smartcontracts web3js etherscan

2
推荐指数
1
解决办法
1万
查看次数

无法验证 Hardhat for Etherscan 的可靠性合约

我正在尝试使用 Hardhat 验证合同源代码并将其提交到 etherscan,但遇到以下错误,并且我不明白如何解决该错误。我已经通读了代码,但我无法发现我做错了什么。请问有人可以建议吗?

我运行时遇到的错误:

npx hardhat verify --network ropsten 0xA16c8f9A5Ab944454D6404CE626E600AF0054aaa 'MyNFTPrice!

错误信息:

Error in plugin @nomiclabs/hardhat-etherscan: The constructor for contracts/MyNFTPrice.sol:MyNFTPrice has 0 parameters but 1 arguments were provided instead.

我的智能合约源文件(MyNFTPrice.sol):

//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

contract MyNFTPrice is ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;

constructor() public ERC721("MyNFTPrice", "NFTPRICE") {}


// Mint new NFT
function mintNFT(address recipient, string memory tokenURI) public payable  {

    require(msg.value …
Run Code Online (Sandbox Code Playgroud)

solidity smartcontracts etherscan hardhat

1
推荐指数
1
解决办法
6273
查看次数