Brownie Setup Change Notice

Diogo Pereira
1 min readFeb 4, 2024

In some of the posts I am using mainly the library along with a personal setup that I shared previously.

From this date on, I’ll be shifting to the brownie python framework and only use library when strictly needed.

Furthermore, due to the deprecation of Rinkeby Ethereum Testnet, I’ll be using Sepolia Testnet.

Setup Instructions

  • Bootstrap the initial repository by issuing: brownie init
  • Create a file in the scripts folder
  • Create a Delegation.sol file in the contracts folder and copy the challenge solidity code over
  • Export the necessary environment variables: WEB3_INFURA_PROJECT_ID and PRIVATE_KEY
  • Add the Sepolia network to brownie networks: brownie networks modify sepolia host=$WEB3_INFURA_PROJECT_ID


# Run brownie in a local blockchain for test purposes
> brownie run -i scripts/
# Run brownie connected to Sepolia network on an Infura Node
> brownie run --network sepolia -i
# Template
from brownie import *
from web3 import Web3
import json
import os
LOCAL = Falsedef read_target_ABI(target_file):
with open(target_file,'r') as key_file:
return json.loads('\n'))['abi']
def main():
hacker = accounts[1]
admin = accounts[0]
target_contract = ContractName.deploy(admin.address, {'from':admin})

hacker = accounts.add(private_key=os.getenv('PRIVATE_KEY'))
target_contract = Contract.from_abi("ContractName", "SOME ADDRESS", read_target_ABI('build/contracts/ContratName.json'))



Diogo Pereira

I help organisations build cyber-resilient applications, bring security awareness and mindset growth tips to interested individuals