Hot answers tagged

11 votes
Accepted

eth-brownie: Unable to expand environment variable in host setting

Typically, this means your environment variables are not set correctly, and it looks like in this case it's your WEB3_INFURA_PROJECT_ID. You can fix it by setting the variable in your .env file and ...
user avatar
9 votes

Which Ethereum framework to choose Truffle vs Brownie?

If you are equally strong in Python and JavaScript, Brownie is a better choice, because Python as a programming language is more suited for tasks needed from a smart contract programming framework. ...
user avatar
7 votes
Accepted

deploying smartcontract to ganache-desktop instead of ganache-cli with brownie

okay. I found the solution. I can add a local network in my network list with : brownie networks add Ethereum ganache-local host=http://127.0.0.1:7545 chainid=5777 where ganache-local is a name i ...
user avatar
  • 295
6 votes
Accepted

How to catch a `revert()` error using Brownie?

The brownie.reverts context manager handles exactly this use case. The syntax is very similar to pytest.raises: import brownie def test_greet(example): with brownie.reverts("Hello World"): ...
user avatar
6 votes
Accepted

How to deploy Ethereum Smart Contract through Brownie to the Private Network

Connecting to the Network First, make sure that Brownie is able to connect to your private network. You will have to add a custom network to Brownie's network settings. Here is an example command ...
user avatar
6 votes

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?

To my knowledge, none of the marketplaces have this functionality of the owner being able to edit the metadata. But with that being said, there is nothing stopping you from including this ...
user avatar
  • 729
5 votes

'Brownie compile' using different compiler version than specified in configuration file

Finally found the root causes of this issue which, if I understood correctly, relates to the generation of interface ABIs at the end of the compile process. Issue #1: No check for a set solc version ...
user avatar
  • 183
4 votes
Accepted

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?

It depends on how you code the NFT. But basically you'd have a function that updates the on-chain metadata and/or updates the tokenURI to reflect the changes, and you'd make it in such a way that only ...
user avatar
4 votes
Accepted

Brownie cannot locate deploy.py script

It's having a hard time finding ganache. You'll need nodejs and npm installed, and then run the following: npm install -g ganache-cli And you should be good to go
user avatar
4 votes

How to use contracts from project dependencies in Brownie scripts?

You're close. The dependencies section identifies where you want to download. You've correctly placed that part using github syntax. You want to download organization OpenZeppelin with repo ...
user avatar
4 votes

LINK1120 error when attempting to install Brownie with 'pipx install eth-brownie'

I too had this problem. I tried installing cytoolz on its own using pip install cytoolz but got an error as well. Found a solution by installing cython using pip install cython Additionally, this ...
user avatar
4 votes
Accepted

Does anyone know how to fork a chain at a particular block on Brownie?

To fork a blockchain with brownie, you actually just need to create a network that uses a forked blockchain or uses a forking command. Option 1: The built-in forked chain Brownie actually comes packed ...
user avatar
4 votes
Accepted

Brownie Chainlink Import Error VSCode - 'File import callback not supported'

So, I figured out a solution. Step 1 - brownie pm install [ORGANIZATION]/[REPOSITORY]@[VERSION]. Do this in your terminal. In my case, it'll be brownie pm install smartcontractkit/chainlink-brownie-...
user avatar
3 votes
Accepted

'Brownie compile' using different compiler version than specified in configuration file

In your brownie-config.yaml file, you'll be able to set a specific version of solidity. However, if a contract specifies a different version, you'll run into an error. It looks like you're using ...
user avatar
3 votes

Can you check if an address is a contract or an EOA with eth-brownie or some other python native package?

web3.py has web3.eth.get_code. Returns the bytecode for the given account at the block specified by block_identifier. From the examples in the documentation # For a contract address. >>> ...
user avatar
  • 29.1k
3 votes
Accepted

Call fallback function from eth-brownie from proxy

You need to use The actual ABI of the implementation instead of the ABI file of the proxy contract Address of the proxy contract from brownie import Box, TransparentUpgradeableProxy, Contract ...
user avatar
3 votes
Accepted

What is the purpose of a `// dev:` comment after a revert or require statement?

This is called a developer revert comment. From the Brownie documentation: Each revert string adds a minimum 20000 gas to your contract deployment cost, and increases the cost for a function to ...
user avatar
3 votes
Accepted

Brownie: PRIVATE_KEY issue: ValueError: The private key must be exactly 32 bytes long, instead of 0 bytes

When working with Brownie and private key environment variables, you'll need to make sure a few things are set. In your .env file, you have your PRIVATE_KEY variable set correctly. If using a .env ...
user avatar
3 votes

File outside of allowed directories on brownie compile command

So basically i accidentally created the brownie-yaml.config file outside of the project folder. some-folder | -project-folder | | -src | | -contracts | | -... brownie-config.yaml once I move ...
user avatar
3 votes
Accepted

Brownie - Constructor Sequence has incorrect length, expected 1 but got 0

Constructor Sequence has incorrect length means the number of parameters you're passing to the deploy function is off. Your constructor is defined as: constructor(address _priceFeed) public { However,...
user avatar
3 votes
Accepted

How to call `brownie run` with extra script parameters

brownie run is designed to be run without any extra arguments besides the ones listed in brownie run -h. All arguments are passed into the docopt function which parses the options based on the ...
user avatar
  • 223
3 votes

'brownie' is not recognized as an internal or external command on Windows 10

I faced this problem today installing brownie on friend's machine. Problem: Was with Pipx paths used for installing/accessing brownie & python. For some reason, even uninstalling and re-installing ...
user avatar
  • 111
3 votes
Accepted

directory is not empty: brownie

This is because there is stuff in your directory already. You can either: Force create the directory brownie init --force Which will create the brownie sample directory alongside your existing code/...
user avatar
3 votes
Accepted

Creating a contract contrainer with Brownie

Import the compiled contract name from brownie from brownie import <ContractName> contract = <ContractName>.deploy(*args) If it is already deployed from brownie import Contract ...
user avatar
  • 181
3 votes
Accepted

Get a state variable from unverified contract

The way how to do this depends on the contract that you want to extract the variable from. If the contract normally provides a function to query this variable you just need to know the correct ...
user avatar
  • 3,719
3 votes
Accepted

delegatecall in Brownie

If you read Brownie's Account class documentation you will find out that the parameters for transfer() are: Account.transfer(self, to=None, amount=0, gas_limit=None, gas_price=None, max_fee=None, ...
user avatar
2 votes
Accepted

Brownie cannot install solc on OSX

The issue is coming from a dependency of Brownie called py-solc-x. From the py-solc-x wiki: The Solidity team does not provide binaries for use with macOS/Darwin. For this reason, py-solc-x ...
user avatar
2 votes
Accepted

Brownie: Hypothesis given() is not resetting chain for each function call

You need to import @given from Brownie, not directly from hypothesis: from brownie.test import given This is required because Brownie handles isolation via a fixture, but function scoped fixtures ...
user avatar
2 votes
Accepted

How to get the return value of a transaction instead of the transaction receipt in brownie

You can use tx.return_value in the transaction receipt or make a .call request. .call which will simulate the transaction going through. Just to note, if you send the transaction again, and then call ....
user avatar
2 votes

How do I get the deployed contract's address from a ContractContainer object in Brownie?

Here is your code with some changes that should work. from brownie import ContractA, ContractB , accounts def main(): acct = accounts[0] container = ContractA.deploy({'from': acct}) ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible