Posts

Showing posts with the label browniepythonframework

Using Brownie to Switch between Different Networks

Image
In this article, we are going to switch between the different available networks we can connect to, using Brownie. Then, we'll write a statement in the Deploy.py to connect to the network requested in the terminal by the user (the developer). This kind of script for network management makes it easy for us to connect to any network that we want at any time it is required for testing and other purposes. How to Switch between Networks As you know, we have different networks to work with. We have already used some of them for deploying our contracts . Sometimes we need to write our deploy.py file in a way that we can switch between different networks and accounts and the deploy.py must understand which ones are available. Switch between Different Networks Before we get started with this task, we can check the keywords when we want to connect to different accounts. To look up the keyword related to any network, we write: Coppied to clipboard. brownie ...

Testing Deploy.py Script Using Brownie: A Full Analysis

Image
In this post, we will complete testing our deploy.py script using Brownie in more detail so that we can see if there is any problem at all. And if there is, we can analyze it in more detail. This kind of detailed test and code analysis becomes handy, especially when the code is too long and complex that we cannot so easily understand where the unexpected result originates from. Detailed Testing Deploy.py Using Brownie For more detailed testing, we can write in the terminal: Coppied to clipboard. brownie test -k Which in our case will be: Coppied to clipboard. brownie test -k test_updating_storage And the result will be: Coppied to clipboard. Brownie v1.18.1 - Python development framework for Ethereum ===================================================== test session starts ===================================================== platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 rootdir: /hom...

How to Interact with Smart Contracts Using Brownie

Image
After installing and working with Ganache CLI , we are going to interact with simple storage smart contracts Using Brownie. Meaning that we want to store and retrieve a value within the contract. After doing this you will see how simple and efficient Brownie is compared to other methods in python. We are also going to use testing modules to test the functionality of the contract and its deployment. Using Brownie to Interact with Smart Contracts In the previous section of this tutorial, we learned how to deploy our simple storage smart contract . In this one, we are going to interact with it, meaning that we want to store a value inside the contract and retrieve it using Brownie. After doing this you will see how simply and efficiently Using Brownie to interact with smart contracts can get compared to other methods in python. Retrieving the Stored Data: So, to follow our deploy.py script, we have: from Brownie import accounts, config, SimpleStorage def dep...

Introduction to Brownie-mix: A Boilerplate for Important Smart Contract Projects

Image
In this article, we are going to get familiar with Brownie-mix as a boilerplate for blockchain projects in python. Using this boilerplate with the Brownie bake command will help you have so many of the dependency contracts provided for that specific project. There is also a complete brownie_config.yaml file provided with a complete list of networks. Some ready python files such as helpful_scripts.py and deploy_mocks.py are provided for you. Introduction to the Brownie-mix When we were examining how to deploy a smart contract using python web3 tools among our previous articles, we showed how to use Brownie. It is highly recommended that before you start this tutorial, be familiar with web3 python tools and also solidity language . So far, we have coded most of our smart contract deployments using Brownie by starting like this in the terminal: Coppied to clipboard. brownie init And then some folders would have been created and then the rest of the p...