Hot answers tagged

8

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. You can handle numbers, like uint256 and decimals, as numbers in Python whereas in JavaScript you need use strings or hacky classes. There are a lot of big ...


6

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"): example.greet() Including the error string is optional, if you omit it you can catch any revert regardless of the message returned. Source: Brownie ...


6

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 that declares a live network with the name "private" at 127.0.0.1, port 8545: brownie networks add live private host=https://127.0.0.1:8545 chainid=1337 You can ...


5

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 adding dotenv: .env to your brownie-config.yaml. brownie-config.yaml: dotenv: .env .env: export WEB3_INFURA_PROJECT_ID=YOUR_PROJECT_ID_HERE Remember to save ...


5

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 functionality in your token contract. But it also depends on what you mean with metadata. Usually, with metadata, we are referring to the name and symbol of the NFT. That's ...


4

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 video has context around fixing the error.


3

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


3

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 https://github.com/eth-brownie/brownie/blob/master/brownie/project/compiler/solidity.py#L108 in the get_abi function, which gets called by when we compile the ...


3

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 execute. Including a revert string for every require and revert statement is often impractical and sometimes simply not possible due to the block gas limit. For this ...


3

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 openzeppelin-contracts. Then, what you want to do is, "remap" your imports so that a keyword you've defined lines up with that package. You're "remapping&...


3

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 choose and where host + chainid is from the running Ganache-desktop version. After running that command you can see a Success message: SUCCESS: A new network '...


3

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 docstring. Any extra arguments that are not listed causes the parser to throw the error you are seeing. You can still use brownie to deploy your contract. But you ...


3

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 pipx did not change the python version/paths being used by it. Eg. We uninstalled v3.10, installed v3.9, reinstalled pipx. Pipx would still go looking for ...


3

Import the compiled contract name from brownie from brownie import <ContractName> contract = <ContractName>.deploy(*args) If it is already deployed from brownie import Contract contract = Contract(*address*) or contract = <ContractName>.at(*address*) or contract = Contract.from_abi( contract_type._name, contract_address,...


3

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 function id to query it. If this is not the case then you can use eth_getStorageAt to query the storage at a specific slot for that contract, but for this you will ...


2

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 attempts to install Solidity on OSX by building it from the source code. Sometimes older versions of Solidity fail to build due to incompatible versions of one or more ...


2

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 only execute once per test (not once per run). From the hypothesis documentation: ... each fixture will run once for the whole function, not once per example. ...


2

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 .call again, it will be different. Here are some examples; requestId is the transaction receipt: requestId = vrf_consumer.getRandomNumber(get_seed, {'from': ...


2

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 account = accounts[0] proxy = TransparentUpgradeableProxy[-1] proxy_box = Contract.from_abi("Box", proxy.address, Box.abi) print(proxy_box.retrieve())


2

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 openzeppelin's 3.4.1 version of their contracts. If you look into the package, you'll see they all use version 0.7 of solidity. You'll either have to: Remove the ...


2

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. >>> web3.eth.get_code('0x6C8f2A135f6ed072DE4503Bd7C4999a1a17F824B') '0x6060604052361561027c5760e060020a60003504630199.....' # For a private key address. >>> ...


2

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 the token owner can call the function. Yes, they would need to know solidity. If you added a function to the NFT contract like: function changeAttributes(...


2

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 file, it should look something like: export PRIVATE_KEY='0xasdfasdfasdfasdfasdfasdfasdfas' If you exported your private key from metamask, you'll want to append ...


2

I was facing the same issue on Windows 20H2, I tried to use npm install -g ganache-cli But did not work for me uninstalled and reinstalled many times. After that, I've checked my node version which was 12.xx and it was the problem. I've upgraded it to 14.18.0 and now the brownie works for me. https://nodejs.org/en/


2

Short answer is: you have to create the API key at etherscan.io either for the mainnet and the rest of public testnets (Ropsten, Rinkeby, Goerli..). (Bonus) In addition, I had some issues when trying to verify a contract with interfaces located in subdirectories. Perhaps it is not your case, but if you are using Truffle to manage the contracts deployment, ...


2

Found this pattern in a yearn repo, maybe this is what you are looking for ? from brownie import project Vault = project.load( Path.home() / ".brownie" / "packages" / config["dependencies"][0] ).Vault


2

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 the .yaml file into the project folder it all works fine


2

Assuming that your initial "deck of cards" is [0, 1, ..., N-1], the following should roughly work. I've made basically no attempt to compile or check this, but the underlying algorithm should be sound. Roughly, the approach is this: You start with a sorted "deck of cards", [0, ..., N-1]. This deck is implicit. To pick a random card, you: ...


2

In order to import directly from github, you need to add the dependencies to your brownie-config.yaml file. ie if you're trying to import from https://github.com/aave/protocol-v2/blob/master/contracts/flashloan/base/FlashLoanReceiverBase.sol you'd need to have in your brownie-config.yaml: dependencies: - aave/protocol-v2@1.0.1 Typically, this is combined ...


2

use pip install eth-brownie. Using pipx wasn't working for me too!!


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