标签: brownie

ParserError:源文件需要不同的编译器版本

我尝试了您在此处的讨论中(在其他问题中)和https://github.com/smartcontractkit/full-blockchain-solidity-course-py/discussions/522中提到的所有内容,但是它并没有为我解决问题,我还注意到当前的编译器版本仍然存在(当前编译器是0.6.12+commit.27d51765.Windows.msvc)。但是当我右键单击并选择Solidty:编译器信息时,它显示0.8.0。

从输出:

Retrieving compiler information:
Compiler using remote version: 'v0.8.0+commit.c7dfd78e', solidity version: 0.8.0+commit.c7dfd78e.Emscripten.clang
Run Code Online (Sandbox Code Playgroud)

不确定这是否与我面临的问题有关。无论如何,从运行布朗尼编译时看到的问题开始。我收到以下错误:

终端错误:

PS D:\Python projects\Solidity dev\demo\smartcontract-lottery> brownie compile
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.6.12
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

C:/Users/rosne/.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.3.0/contracts/access/Ownable.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Windows.msvc) - note that nightly builds are considered to be strictly …
Run Code Online (Sandbox Code Playgroud)

python ethereum solidity smartcontracts brownie

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

Brownie.exceptions.RPCRequestError:Web3 未连接

我正在尝试使用布朗尼部署 helloWorld.sol。当我尝试运行Brownie run scripts/deploy.py时,出现以下错误。

正在终止本地 RPC 客户端...线程 Thread-5 中出现异常:回溯(最近一次调用最后一次):文件“C:\Users\mmasn.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connection .py”,第 175 行,在 _new_conn (self._dns_host, self.port),self.timeout,**extra_kw 文件“C:\Users\mmasn.local\pipx\venvs\eth-brownie\lib\site-packages \urllib3\util\connection.py”,第 96 行,在 create_connection 中
引发错误文件“C:\Users\mmasn.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\util\connection.py” ,第 86 行,在 create_connection
sock.connect(sa) ConnectionRefusedError: [WinError 10061] 无法建立连接,因为目标计算机主动拒绝它

在处理上述异常的过程中,又出现了一个异常:

回溯(最近一次调用最后一次):文件“C:\Users\mmasn.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connectionpool.py”,第 706 行,在 urlopen chunked=chunked,文件中“C:\Users\mmasn.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connectionpool.py”,第 394 行,在 _make_request conn.request(method, url, **httplib_request_kw) 文件中“ C:\Users\mmasn.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connection.py",第 239 行,请求 super(HTTPConnection, self).request(method, url, body= body,headers=headers)文件“C:\ Program Files \ Python37 \ lib \ http \ client.py”,第1229行,请求self._send_request(方法,url,body,headers,encode_chunked)文件“C:\ Program文件\Python37\lib\http\client.py”,第1275行,在_send_request self.endheaders(body,encode_chunked=encode_chunked)文件“C:\Program Files\Python37\lib\http\client.py”,第1224行,在 endheaders self._send_output(message_body,encode_chunked=encode_chunked) 文件“C:\Program Files\Python37\lib\http\client.py”,第 1016 行,在 _send_output self.send(msg) 文件“C:\Program Files\ Python37\lib\http\client.py”,第 956 行,发送 …

brownie

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

WalletBalance.tsx 代币余额返回:未定义

我已经完成了全栈 defi 课程,当我使用usedapp/core 中的 useTokenBalance 函数时,我没有返回任何内容,我不知道我哪里出了问题,因为当我 console.log 地址时以及它返回的帐户变量以及正确的帐户地址和正确的令牌地址。 在此输入图像描述

这是这里的打字稿:

import {useEthers, useTokenBalance} from "@usedapp/core"
import {formatUnits} from "@ethersproject/units"

export interface WalletBalanceProps {
    token: Token
}

export const WalletBalance = ({token}: WalletBalanceProps) => {
    const {image, address, name} = token
    const {account} = useEthers()
    console.log(account)
    console.log(address)
    const tokenBalance = useTokenBalance(address, account)
    const formattedTokenBalance: number = tokenBalance ? parseFloat(formatUnits(tokenBalance, 18)) : 0
    console.log(tokenBalance?.toString())
    return (<div>{formattedTokenBalance}</div>)
}
Run Code Online (Sandbox Code Playgroud)

我认为这可能是 @usedapp/core 的错误,但我重新安装了 @usedapp/core 并且仍然返回相同的错误。任何帮助都会有用的:)

typescript solidity brownie usedapp

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

如何动态导入类似于Python中“import X from Y”语法的模块?

我正在努力实现:

from X import Y
Run Code Online (Sandbox Code Playgroud)

其中 Y 是仅在运行时才知道的模块的字符串名称。

我尝试过使用

module = importlib.import_module(Y, X)
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。我也不知道模块的路径,因为它仅在运行时存在于模块 Brownie 中,然后被删除。

非常感谢帮助。

python python-import brownie

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