Questions tagged [brownie]
Brownie is a Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
387
questions
9
votes
5
answers
5k
views
eth-brownie: Unable to expand environment variable in host setting
When running a script:
brownie run scripts/deploy.py --network kovan
I receive this error:
raise ValueError(f"Unable to expand environment variable in host setting: ‘{uri}’”)
ValueError: Unable ...
9
votes
2
answers
6k
views
Which Ethereum framework to choose Truffle vs Brownie?
I know that the most used framework for smart contract that is used for testing, deployment etc is Truffle. But, since I am not very good at javascript (i am mainly coding in python)- I saw there is ...
7
votes
4
answers
1k
views
How to debug Brownie in VSCode?
How to debug Brownie program in Visual Studio Code? I suppose there should be some launch.json created but don't know which one.
6
votes
1
answer
2k
views
How to catch a `revert()` error using Brownie?
I am using Brownie to develop my smart contracts, which helps me to intract with the smart contracts, please see doc.
When my call Example.greet() is there any way to return the error message and act ...
6
votes
1
answer
2k
views
How to deploy Ethereum Smart Contract through Brownie to the Private Network
I have a geth node that is connected to a private network on my computer that uses port: 8545. Hence, I have a smart contract that is tested using Brownie on the ganache-cli network.
Brownie is a ...
6
votes
2
answers
4k
views
How to get the return value of a transaction instead of the transaction receipt in brownie
I have a function in my smart contract called getRandomNumer, and it returns a bytes32. However, in brownie, when I make a transaction it returns the transaction receipt.
How do I get the return value?...
5
votes
2
answers
2k
views
deploying smartcontract to ganache-desktop instead of ganache-cli with brownie
i have a smartcontract developed with brownie. I want to deploy it to ganache. If i run my deployment script brownie run scripts/deploy.py, brownie deploys the smartcontract with ganache-cli. But i ...
5
votes
1
answer
2k
views
Can you check if an address is a contract or an EOA with eth-brownie or some other python native package?
I'm trying to categorize smart contracts versus EOAs since I am treating them differently in an application. Does anyone have ideas?
I know in solidity you could try address.code.length or extcodesize ...
5
votes
2
answers
2k
views
'brownie' is not recognized as an internal or external command on Windows 10
I downloaded eth brownie via
pipx install eth-brownie
and got
'eth-brownie' already seems to be installed. Not modifying existing installation in 'C:\\Users\\HP\\.local\\pipx\\venvs\\eth-brownie'. ...
5
votes
0
answers
147
views
Brownie empty traceback and revert_msg
I'm trying to create a Yearn strategy following https://github.com/yearn/brownie-strategy-mix.
But a transaction is failing, and brownie isn't telling me why:
% brownie console
Brownie environment is ...
4
votes
3
answers
5k
views
How can I make an ERC721 NFT such that the token owner can edit an attribute in the metadata? Where can they edit the metadata?
I've read that ERC721 tokens can be created such that the token owner can edit the on-chain metadata. I've been following tutorials for the brownie-nft mix and making NFTs on OpenSea, but I have yet ...
4
votes
3
answers
1k
views
directory is not empty: brownie
I'm getting this error when I try to setup a brownie project using brownie init. I initially installed brownie using pip install eth-brownie in the virtual environment. The folder .venv is present ...
4
votes
2
answers
2k
views
How to use contracts from project dependencies in Brownie scripts?
I want to deploy a contract directly accessible in OpenZeppelin/openzeppelin-contracts@4.2.0 Brownie package without changes, namely ERC1967Proxy
and other non-abstract contracts from Brownie console.
...
4
votes
4
answers
2k
views
Brownie Chainlink Import Error VSCode - 'File import callback not supported'
The code seems to have successfully compiled, but VSCode keeps showing this error -
"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found. File import callback not ...
4
votes
1
answer
135
views
Brownie: Hypothesis given() is not resetting chain for each function call
I have the following test code snippet in my brownie project:
from hypothesis import settings, given, strategies as st
from brownie import *
import brownie
st_buy_amount_eth = st.integers(min_value=...
3
votes
2
answers
2k
views
'Brownie compile' using different compiler version than specified in configuration file
Why does brownie attempt to compile with the latest locally available version of solc even if I set a specific older version in the config file?
Example:
bernat:uniswap-v3-playground bernat$ brownie ...
3
votes
1
answer
2k
views
Does anyone know how to fork a chain at a particular block on Brownie?
I am trying to fork the ethereum mainnet at a past block number on brownie. But I dont see any way to do that in the brownie docs .
3
votes
7
answers
3k
views
LINK1120 error when attempting to install Brownie with 'pipx install eth-brownie'
I'm having some issues with my installation process for Brownie and wanted to reach out for some help. After getting pipx installed, my attempt to use 'pipx install eth-brownie' in the terminal of VSS ...
3
votes
3
answers
2k
views
Brownie cannot locate deploy.py script
I have python installed on my system (Windows) with Anaconda from a prior course I had taken which may be the root cause of the issue. I'm at the stage where I need to run a deploy.py script to deploy ...
3
votes
2
answers
751
views
Call fallback function from eth-brownie from proxy
I have a contract that has a fallback function to delegatecall all function calls to a different contract. I can't seem to use my typical API to interact with the contract it delegates a call to.
I ...
3
votes
1
answer
231
views
delegatecall in Brownie
I am trying to perform delegatecall in Brownie solving the Delegation task in the Ethernaut app in order to claim ownership of the Delegate contract (see below).
What is the equivalent of the ...
3
votes
3
answers
2k
views
Brownie: Unable to launch local RPC client
I was trying to run brownie for ganachi-cli, but it keeps giving me this error. My node is up to date and I have changed my host in the ganachi-cli UI. What do I do?
Brownie v1.17.2 - Python ...
3
votes
1
answer
246
views
What is the purpose of a `// dev:` comment after a revert or require statement?
What does it mean when a Solidity contract includes a comment starting with // dev: after a revert or require statement?
For example:
contract Example {
function greet(){
revert(); // ...
3
votes
2
answers
354
views
Add a 'from' account to hardhat transaction calls
I recently started learning to use hardhat to interact with and deploy smart contracts and I noticed that while brownie can accept a from address field for chain transactions, hardhat doesn't.
Does ...
3
votes
1
answer
343
views
how do i solve KeyError: 'wallets'?
I followed the answer to a similar question posted on here by adding dotenv: .env to the top of my brownie-config.yaml file but still having the same issue.
This is my code in the brownie-config.yaml ...
3
votes
1
answer
781
views
Deploy to testnet with brownie
I'm looking to deploy some code to the kovan testnet with Brownie. However I keep getting an error accessing accounts. Here is the command I'm running:
brownie run scripts/deploy_price_consumer_v3.py -...
3
votes
1
answer
1k
views
Brownie cannot install solc on OSX
Follow the procedures on this page brownie : create new project and compile with brownie. Encounter the following error, please comment how to fix it.
Configuration and environment.
Python 3.7.7
...
3
votes
1
answer
1k
views
How to re-use previously deployed contract with Hardhat?
In brownie there's a very handy syntax to avoid deploying multiple times the same contract on-chain, while developing and iterating fast:
MyContract.deploy()
# somewhere else, sometime later:
...
3
votes
3
answers
304
views
How to run a specific unit test in a test script in brownie?
Say I have a python test script in my brownie project's /tests directory with a number of difference test cases, is it possible to pass a flag to only execute a certain test function in brownie?
3
votes
2
answers
1k
views
Brownie / Rinkeby ValueError: Gas estimation failed: "you must set the gas limit manually"
from brownie import AdvancedCollectible, accounts, config, network
from scripts.helpful_scripts import get_breed
import time
static_seed = 123
def main():
dev = accounts.add(config["wallets&...
3
votes
2
answers
4k
views
Error: Non-hexadecimal digit found
I seem to be running the following error when I try to run this script: ,
from brownie import AdvancedCollectible, accounts, network, config
def main():
dev = accounts.add(config['wallets']['...
3
votes
0
answers
197
views
Does brownie have functionality to analyze gas costs for all function calls?
Does brownie have any sort of functionality that gives a breakdown of the cost to deploy all contracts and execute all function calls within a brownie project with min, max and average gas cost ...
3
votes
1
answer
243
views
AttributeError: 'UsingForDirective' object has no attribute 'typeName'
I'm trying to compile code from OHM BondDepository.sol contract however every time I do so, I get this error from brownie
Compiling contracts...
Solc version: 0.7.5
Optimizer: Enabled Runs: 200
...
3
votes
0
answers
678
views
Brownie INFO: Could not find files for the given pattern(s)
I installed Brownie succefully, and also am able to make a init project from it. But every time I run brownie I get
INFO: Could not find files for the given pattern(s)
I've installed ganache-cli, ...
3
votes
2
answers
456
views
How to run Chainlink Project using eth-brownie python
I had installed eth-brownie using command
pip install eth-brownie
after Brownie installed.I had bake existing Brownie project into a new directory.
mkdir MyChainlinkProject
cd MyChainlinkProject/
...
3
votes
1
answer
157
views
How do I automatically verify my contracts on etherscan using brownie?
I discovered truffle has truffle-plugin-verify that help you verify your contracts on etherscan. I wonder if similar functionality can be done with brownie ?
2
votes
2
answers
111
views
What are the node providers for Genosis Network (xDai)?
Which node provider can be used to fork Genosis Network (xDai) using brownie? Alchemy, infura and moralis does not provide service. I tried getBlock but doesn't work at all.
2
votes
5
answers
2k
views
File outside of allowed directories on brownie compile command
trying to import to files from openzeppelin and chainlink in my contract file like so:
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/...
2
votes
2
answers
792
views
How to get a contracts emitted events in brownie?
Say I have a contract that emits multiple events, how do I to get a list of all events emitted in brownie and sort them by event type?
contract SimpleContract {
event Deposit(address indexed ...
2
votes
2
answers
138
views
How to use vyper's external_interface in brownie?
An external interface can be generated by vyper as such:
vyper -f external_interface contracts/CurveCryptoSwap.vy
Doing that results in the following output:
# External Interfaces
interface ...
2
votes
2
answers
327
views
Brownie deployment – KeyError: 'OpenZeppelin/openzeppelin-contracts@4.4.0/Address'
I'd been building with v3.4 of Zeppelin contracts for a while without issues. I just started a new project using v4.4.0 and I'm getting the following error when I try and publish my contract ...
2
votes
2
answers
1k
views
Brownie - Constructor Sequence has incorrect length, expected 1 but got 0
I am trying to deploy a contract on Rinkeby by running brownie run scripts/deploy.py --network rinkeby but I get following error:
Constructor Sequence has incorrect length, expected 1 but got 0
I ...
2
votes
3
answers
6k
views
Brownie: PRIVATE_KEY issue: ValueError: The private key must be exactly 32 bytes long, instead of 0 bytes
I am trying to run a script in brownie, but I'm running into this error:
ValueError: The private key must be exactly 32 bytes long, instead of 0 bytes.
Terminating local RPC client...
I'm using a ....
2
votes
1
answer
99
views
How to dump/access contract storage in Brownie console?
In Brownie console, for a deployed contract, public contract attributes can be accessed with contract.nameOfAttribute(). This does not work for private attributes - how can one access private ...
2
votes
1
answer
153
views
ValueError: Unknown URI
I'm following a solidity tutorial from Patrick Collins and when trying to run the following:
brownie run scripts/get_weth.py --network mainnet-fork
I get an error:
INFO: Could not find files for the ...
2
votes
2
answers
514
views
Passing struct into solidity function from brownie
Similar questions have been asked before, and I have read them but am stuck after using encode_single. If I pass the resulting bytes into my solidity function it says "expected list or tuple, ...
2
votes
2
answers
387
views
Convert an address into a ContractContainer in Brownie
I have a factory contract, that in a transaction:
Deploys a contract
Emits an event with the address of the contract it deployed
I want to be able to use the address returned to interface with the ...
2
votes
1
answer
539
views
How to test internal members of solidity library or contract in brownie?
Say I have the following SimpleMath solidity library defined as follows:
library SimpleMath {
function add(uint a, uint b) internal pure returns(uint)
{
return a + b;
}
}
How do I import ...
2
votes
1
answer
931
views
Can’t Install Eth-Brownie on Windows 10: pipx fails to build cytoolz, saying that "Microsoft Visual C++ 14.0 or greater is required"
Good evening! I'm going through the Free Code Camp Solidity/Blockchain tutorial and for the life of me, I cannot get Brownie to install properly.
When I try and install through pipx I get the ...
2
votes
1
answer
805
views
Send transaction with Brownie without confirmation wait
Is there is a way in Brownie to send a transaction without waiting for confirmation, like an async way?