【问题标题】:Python: Error 54 'Connection reset by peer'Python:错误 54“对等方重置连接”
【发布时间】:2022-01-05 20:46:56
【问题描述】:

我收到以下错误:ChunkedEncodingError: ("Connection broken: ConnectionResetError(54, 'Connection reset by peer') 下载时:从https://solc-bin.ethereum.org/macosx-amd64/solc-macosx-amd64-v0.8.11+commit.d7f03943 下载。请告诉我如何解决这个问题。谢谢你提前!!!

代码如下:

// SPDX-License-Identifier: MIT
pragma solidity ^0.4.11;

import "@chainlink/contracts/src/v0.4/ERC677Token.sol";
import {StandardToken as linkStandardToken} from "@chainlink/contracts/src/v0.4/vendor/StandardToken.sol";

contract LinkToken is linkStandardToken, ERC677Token {
    uint256 public constant totalSupply = 10**27;
    string public constant name = "ChainLink Token";
    uint8 public constant decimals = 18;
    string public constant symbol = "LINK";

    function LinkToken() public {
        balances[msg.sender] = totalSupply;
    }

    /**
     * @dev transfer token to a specified address with additional data if the recipient is a contract.
     * @param _to The address to transfer to.
     * @param _value The amount to be transferred.
     * @param _data The extra data to be passed to the receiving contract.
     */
    function transferAndCall(
        address _to,
        uint256 _value,
        bytes _data
    ) public validRecipient(_to) returns (bool success) {
        return super.transferAndCall(_to, _value, _data);
    }

    /**
     * @dev transfer token to a specified address.
     * @param _to The address to transfer to.
     * @param _value The amount to be transferred.
     */
    function transfer(address _to, uint256 _value)
        public
        validRecipient(_to)
        returns (bool success)
    {
        return super.transfer(_to, _value);
    }

    /**
     * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
     * @param _spender The address which will spend the funds.
     * @param _value The amount of tokens to be spent.
     */
    function approve(address _spender, uint256 _value)
        public
        validRecipient(_spender)
        returns (bool)
    {
        return super.approve(_spender, _value);
    }

    /**
     * @dev Transfer tokens from one address to another
     * @param _from address The address which you want to send tokens from
     * @param _to address The address which you want to transfer to
     * @param _value uint256 the amount of tokens to be transferred
     */
    function transferFrom(
        address _from,
        address _to,
        uint256 _value
    ) public validRecipient(_to) returns (bool) {
        return super.transferFrom(_from, _to, _value);
    }

    // MODIFIERS

    modifier validRecipient(address _recipient) {
        require(_recipient != address(0) && _recipient != address(this));
        _;
    }
}

这是一条错误消息:

Downloading from https://solc-bin.ethereum.org/macosx-amd64/solc-macosx-amd64-v0.8.11+commit.d7f03943
 37%|████████████████████████████████████████████▉                                                                             | 14.2M/38.5M [00:53<01:32, 264kiB/s]
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/run.py", line 40, in main
    active_project = project.load()
  File "brownie/project/main.py", line 751, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 183, in __init__
    self.load()
  File "brownie/project/main.py", line 238, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 95, in _compile
    build_json = compiler.compile_and_format(
  File "brownie/project/compiler/__init__.py", line 105, in compile_and_format
    find_solc_versions(solc_sources, install_needed=True, silent=silent)
  File "brownie/project/compiler/solidity.py", line 173, in find_solc_versions
    install_solc(*to_install)
  File "brownie/project/compiler/solidity.py", line 105, in install_solc
    solcx.install_solc(version, show_progress=True)
  File "solcx/install.py", line 454, in install_solc
    _install_solc_unix(version, filename, show_progress, solcx_binary_path)
  File "solcx/install.py", line 603, in _install_solc_unix
    content = _download_solc(download, show_progress)
  File "solcx/install.py", line 589, in _download_solc
    for data in response.iter_content(1024, decode_unicode=True):
  File "requests/utils.py", line 536, in stream_decode_response_unicode
    for item in iterator:
  File "requests/models.py", line 761, in generate
    raise ChunkedEncodingError(e)
ChunkedEncodingError: ("Connection broken: ConnectionResetError(54, 'Connection reset by peer')", ConnectionResetError(54, 'Connection reset by peer'))

【问题讨论】:

  • 好奇:你的代码的上下文是什么?为什么要使用这么旧版本的solidity?

标签: python solidity chainlink


【解决方案1】:

错误是在solidity编译器下载中,你可以寻找另一个链接来下载它。 solc-bin.ethereum.org 已弃用。

以下是更新链接: https://docs.soliditylang.org/en/latest/installing-solidity.html#static-binaries

一条评论:它正在尝试下载solidity 0.8.11。 即使代码适用于版本 ^0.4.11,它也不适用于此编译器版本。

您可以检查重大更改

https://docs.soliditylang.org/en/latest/080-breaking-changes.html

【讨论】:

  • 非常感谢您的回复。看起来 0.8.11 已经安装并且是最新的“brew install solidity 警告:solidity 0.8.11 已经安装并且是最新的。”但它仍然试图从已弃用的链接下载并最终出现错误。另外,你能帮我弄清楚你最后的评论吗?非常新手,不知道如何解决最后一点。
  • 在solidity 0.4.11 版本中创建的合约将无法使用solidity 0.8.11 版本进行编译。你会得到一些编译错误。上面与重大更改相关的链接列出了一些不兼容性。您可以检查从 0.4.x 到 0.5.x 及以下,直到版本 0.8.x
  • 我通过 brew 安装了solidity,solidity@7&6,但仍然“brownie compile”导致通过已弃用的链接 (solc-bin) 下载 solc。在这一点上,我刚刚烘焙了 chainlnk-mix 并运行了 brownie compile 并得到了同样的错误。因此,这不是编码错误,而是设置或某种形式。任何帮助表示赞赏!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-12-07
  • 2020-07-10
  • 1970-01-01
  • 2016-10-07
  • 2017-04-12
  • 2017-06-09
  • 2016-12-15
相关资源
最近更新 更多