Coder Social home page Coder Social logo

smartcontractkit / full-blockchain-solidity-course-py Goto Github PK

View Code? Open in Web Editor NEW
10.6K 248.0 2.9K 230 KB

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition

License: MIT License

ethereum blockchain solidity smart-contracts dapp chainlink web3

full-blockchain-solidity-course-py's People

Contributors

0xabhisek avatar 7xaquarius avatar achimstruve avatar bsilagani avatar chalex-eth avatar cromewar avatar damdafayton avatar freddie71010 avatar ivpavici avatar jethr0null avatar michaelbnewman avatar n4n0b1t3 avatar omnifient avatar patrickalphac avatar sevamove avatar sk-azraf-sami avatar zeuslawyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

full-blockchain-solidity-course-py's Issues

Lesson 11 Pinata api keys error

Hi all

I'm having an issue with the pinata api, when I try to upload my files this error pops up
image

my keys are stored like this in my .env

export PINATA_API_KEY=d88a99cdc680f3723da6
(secret key is also stored like this)

I'm I missing something?, The code is a perfect copy of the one at this link without the final if

Lesson 4 venv path problem

Hello,
I get the following error when trying to run python deploy.py (i have venv downloaded and activated):

/Library/Frameworks/Python.framework/Versions/3.9/bin/python3: can't open file '/Users/khalidhamid/demos/web3_py_simple_storage/deploy.py': [Errno 2] No such file or directory

This is how my files are saved:
Screen Shot 2021-10-07 at 12 28 02 PM
y

Brownie does not import OpenZeppelin onlyOwner

Course at 6:32:??

It's probably just a distraction error but I can't seem to understand what I'm doing wrong, I can't compile Lottery.sol, these are my import and dependecies, what am I missing?

image
image

Thanks

Chapter 6: Brownie Fund Me import error

Error message on import statement
Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File import callback not supported


// SPDX-License-Identifier: MIT

pragma solidity ^0.6.6;

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";

Screenshot (61)

Dependencies (brownie-config.yaml)

-dependencies:
  - smartcontractkit/[email protected]
compiler:
  solc:
    remappings:
      - "@chainlink=smartcontractkit/[email protected]"

Error installing web3 using pip

  • Python: 3.8.10
  • OS: win
  • pip freeze output
backports.entry-points-selectable==1.1.0
base58==2.1.0
black==21.9b0
certifi==2021.5.30
chardet==4.0.0
charset-normalizer==2.0.6
click==8.0.1
colorama==0.4.4
cytoolz==0.11.0
distlib==0.3.3
eth-abi==2.1.1
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
filelock==3.3.0
hexbytes==0.2.2
idna==3.2
multiaddr==0.0.9
multidict==5.2.0
mypy-extensions==0.4.3
netaddr==0.8.0
parsimonious==0.8.1
pathspec==0.9.0
platformdirs==2.4.0
py-solc-x==1.1.0
pycryptodome==3.10.4
pyrsistent==0.18.0
regex==2021.9.30
requests==2.26.0
rlp==2.0.1
semantic-version==2.8.5
six==1.16.0
tomli==1.2.1
toolz==0.11.1
typing-extensions==3.10.0.2
urllib3==1.26.7
varint==1.0.2
virtualenv==20.8.1
yarl==1.6.3

What was wrong?

with the pip install web3 I get the following error:

Collecting web3
  Using cached web3-5.24.0-py3-none-any.whl (487 kB)
Collecting protobuf<4,>=3.10.0
  Using cached protobuf-3.18.0-cp38-cp38-win_amd64.whl (912 kB)
Collecting lru-dict<2.0.0,>=1.1.6
  Using cached lru-dict-1.1.7.tar.gz (10 kB)
Requirement already satisfied: eth-utils<2.0.0,>=1.9.5 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from web3) (1.10.0)
Collecting eth-account<0.6.0,>=0.5.6
  Using cached eth_account-0.5.6-py3-none-any.whl (101 kB)
Requirement already satisfied: hexbytes<1.0.0,>=0.1.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from web3) (0.2.2)
Requirement already satisfied: eth-hash[pycryptodome]<1.0.0,>=0.2.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from web3) (0.3.2)
Requirement already satisfied: eth-typing<3.0.0,>=2.0.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from web3) (2.2.2)
Requirement already satisfied: requests<3.0.0,>=2.16.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from web3) (2.26.0)
Collecting aiohttp<4,>=3.7.4.post0
  Using cached aiohttp-3.7.4.post0-cp38-cp38-win_amd64.whl (635 kB)
Collecting websockets<10,>=9.1
  Using cached websockets-9.1-cp38-cp38-win_amd64.whl (90 kB)
Collecting pywin32>=223
  Using cached pywin32-301-cp38-cp38-win_amd64.whl (9.3 MB)
Requirement already satisfied: eth-abi<3.0.0,>=2.0.0b6 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from web3) (2.1.1)
Collecting ipfshttpclient==0.8.0a2
  Using cached ipfshttpclient-0.8.0a2-py3-none-any.whl (82 kB)
Collecting jsonschema<4.0.0,>=3.2.0
  Using cached jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
Requirement already satisfied: multiaddr>=0.0.7 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from ipfshttpclient==0.8.0a2->web3) (0.0.9)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (5.2.0)
Collecting attrs>=17.3.0
  Using cached attrs-21.2.0-py2.py3-none-any.whl (53 kB)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (1.6.3) 
Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (4.0.0)
Collecting async-timeout<4.0,>=3.0
  Using cached async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from aiohttp<4,>=3.7.4.post0->web3) (3.10.0.2)
Requirement already satisfied: parsimonious<0.9.0,>=0.8.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from eth-abi<3.0.0,>=2.0.0b6->web3) (0.8.1)
Requirement already satisfied: eth-rlp<2,>=0.1.2 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from eth-account<0.6.0,>=0.5.6->web3) (0.2.1)
Requirement already satisfied: rlp<3,>=1.0.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from eth-account<0.6.0,>=0.5.6->web3) (2.0.1)Collecting bitarray<1.3.0,>=1.2.1
  Using cached bitarray-1.2.2.tar.gz (48 kB)
Requirement already satisfied: eth-keyfile<0.6.0,>=0.5.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from eth-account<0.6.0,>=0.5.6->web3) (0.5.1)
Requirement already satisfied: eth-keys!=0.3.2,<0.4.0,>=0.2.1 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from eth-account<0.6.0,>=0.5.6->web3) (0.3.3)
Requirement already satisfied: pycryptodome<4,>=3.6.6 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from eth-hash[pycryptodome]<1.0.0,>=0.2.0->web3) (3.10.4)
Requirement already satisfied: cytoolz<1.0.0,>=0.9.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from eth-keyfile<0.6.0,>=0.5.0->eth-account<0.6.0,>=0.5.6->web3) (0.11.0)
Requirement already satisfied: toolz>=0.8.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from cytoolz<1.0.0,>=0.9.0->eth-keyfile<0.6.0,>=0.5.0->eth-account<0.6.0,>=0.5.6->web3) (0.11.1)
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (0.18.0)
Requirement already satisfied: setuptools in c:\program files\windowsapps\pythonsoftwarefoundation.python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (56.0.0)
Requirement already satisfied: six>=1.11.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (1.16.0)  
Requirement already satisfied: varint in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from multiaddr>=0.0.7->ipfshttpclient==0.8.0a2->web3) (1.0.2)
Requirement already satisfied: netaddr in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from multiaddr>=0.0.7->ipfshttpclient==0.8.0a2->web3) (0.8.0)
Requirement already satisfied: base58 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from multiaddr>=0.0.7->ipfshttpclient==0.8.0a2->web3) (2.1.0)
Requirement already satisfied: idna<4,>=2.5 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests<3.0.0,>=2.16.0->web3) (3.2)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests<3.0.0,>=2.16.0->web3) (2021.5.30)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests<3.0.0,>=2.16.0->web3) (2.0.6)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\dmrar\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from requests<3.0.0,>=2.16.0->web3) (1.26.7)
Using legacy 'setup.py install' for bitarray, since package 'wheel' is not installed.
Installing collected packages: bitarray, attrs, async-timeout, websockets, pywin32, protobuf, lru-dict, jsonschema, ipfshttpclient, eth-account, aiohttp, web3
    Running setup.py install for bitarray ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\dmrar\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\dmrar\\AppData\\Local\\Temp\\pip-install-_h1l3zdm\\bitarray_557ab97a05904491a24dc21176f20c13\\setup.py'"'"'; __file__='"'"'C:\\Users\\dmrar\\AppData\\Local\\Temp\\pip-install-_h1l3zdm\\bitarray_557ab97a05904491a24dc21176f20c13\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\dmrar\AppData\Local\Temp\pip-record-z3e9lpr_\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\dmrar\AppData\Local\Packages\Pyth         cwd: C:\Users\dmrar\AppData\Local\Temp\pip-install-_h1l3zdm\bitarray_557ab97a05904491a24dc21176f20c13\
    Complete output (13 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    creating build\lib.win-amd64-3.8\bitarray
    copying bitarray\test_bitarray.py -> build\lib.win-amd64-3.8\bitarray
    copying bitarray\test_util.py -> build\lib.win-amd64-3.8\bitarray
    copying bitarray\util.py -> build\lib.win-amd64-3.8\bitarray
    copying bitarray\__init__.py -> build\lib.win-amd64-3.8\bitarray
    running build_ext
    building 'bitarray._bitarray' extension
    error: [WinError 2] The system cannot find the file specified
    ----------------------------------------
\\Users\\dmrar\\AppData\\Local\\Temp\\pip-install-_h1l3zdm\\bitarray_557ab97a05904491a24dc21176f20c13\\setup.py'"'"'; __file__='"'"'C:\\Users\\dmrar\\AppData\\Local\\Temp\\pip-install-_h1l3zdm\\bitarray_557ab97a05904491a24dc21176f20c13\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\dmrar\AppData\Local\Temp\pip-record-z3e9lpr_\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\dmrar\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Include\bitarray' Check the logs for full command output.

I am following the freeCodeCamp.org tutorial on youtube: https://www.youtube.com/watch?v=M576WGiDBdQ&t=190s and

What can I do to install web3 properly?

Strange behaviour of the buildTransaction method

Hi everyone

I don't seem to understand but I opened ganache and the network id is 5777 but when I print the transaction variable (4:00:28)
it gives me this error:

web3.exceptions.ValidationError: The transaction declared chain ID 5777, but the connected node is on 1337
image

When I change the id to 1337 it works just fine but I don't understand why it behaves like this, I would't like if it can become a bigger problem in the future so it's better to ask now

Thanks

Tx Dropped without replacement

Hi ,
Sometimes my transactions fail with the below error. I understand its probably a new block getting added by the time our transaction gets in. But is there a workaround.

Sometimes it fails due to other errors and simply works on rerunning the deploy script
image

Stuck at start of lesson 9

I'm trying to compile the OurToken contract and it gives me this error but I don't understand why since the version of the compiler I set in vs code is 0.8.0+commit.c7dfd78e

The OurToken contract is a perfect copy of the one in the tutorial
image

Error after Deploying Mocks

Hello,
everything did work perfectly fine before I putted in the MockV3Aggregator.

I exactly followed every step from Patrick, netherless when I do brownie run scripts/deploy.py I get this error:

Bildschirmfoto 2021-09-21 um 00 51 48

Something I noticed is, that the Terminal also shows this 3 source Problems:

Bildschirmfoto 2021-09-21 um 00 53 14

The 2 source Problem in FundMe.sol didn't gave me trouble, everything worked, after MockV3Aggregator came, I had trouble.

Here is the deploy.py, just wanted to provide it, if it helps:

Bildschirmfoto 2021-09-21 um 01 03 47

I would be really thankful for help.

Import SimpleStorage from brownie

Hi,
I am getting this error when I try to import SimpleStorage from brownie.
Does anyone know how can I solve it

Launching 'ganache-cli.cmd --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
File "C:\Users\gonca\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie_cli\run.py", line 49, in main
return_value, frame = run(
File "C:\Users\gonca\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\project\scripts.py", line 53, in run
module = _import_from_path(script)
File "C:\Users\gonca\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\project\scripts.py", line 149, in _import_from_path
import_cache[import_str] = importlib.import_module(import_str)
File "C:\Users\gonca\AppData\Local\Programs\Python\Python310\lib\importlib_init
.py", line 126, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File "<frozen, line line, in in
File ".\scripts\deploy.py", line 1, in
from brownie import accounts, config, SimpleStorage
ImportError: cannot import name 'SimpleStorage' from 'brownie' (C:\Users\gonca\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie_init
.py)
Terminating local RPC client...

Lesson 6 (Brownie FundMe) - Having trouble interacting with deployed FundMe contract

Hi Everyone.

I am having trouble interacting with the deployed "FundMe" contract in Lesson 5, via fund_and_withdraw.py. The specific time in the video is 5:44:38

The problem occurs at line "fund_me.getEntranceFee()" - i even tried other functions such as "getVersion()" but no luck.

The contracts appear to deploy successfully and the transactions for contract creation are viewable in my ganache UI.

Any ideas?

The output from terminal is below:

PS C:\Users\XXXXX\Downloads\brownie_fund_me> brownie run .\scripts\deploy.py --network ganache-local

INFO: Could not find files for the given pattern(s).
Brownie v1.16.4 - Python development framework for Ethereum

BrownieFundMeProject is the active project.
Running 'scripts\deploy.py::main'...
The active network is ganache-local
Deploying Mocks...
Transaction sent: 0xfeda920b7936699419d47e25fb22b5bbe160603e8424fee4b86fc9fbe7c5eb52
  Gas price: 20.0 gwei   Gas limit: 473790   Nonce: 0
  MockV3Aggregator.constructor confirmed   Block: 1   Gas used: 430719 (90.91%)
  MockV3Aggregator deployed at: 0x4Ee6FA77002090365f8750BB70ba713229cC0921

Mocks Deployed!
Transaction sent: 0xf07a5a5ece530f98f3c48807aac9cee196fcae6a67e9a69265704e2616874301
  Gas price: 20.0 gwei   Gas limit: 424509   Nonce: 1
  FundMe.constructor confirmed   Block: 2   Gas used: 385918 (90.91%)
  FundMe deployed at: 0x28E997DF1Fee9C0145975DCA4ACe227FcA976dE6

Contract Deployed to 0x28E997DF1Fee9C0145975DCA4ACe227FcA976dE6

PS C:\Users\XXXXX\Downloads\brownie_fund_me> brownie run .\scripts\fund_and_withdraw.py --network ganache-local

INFO: Could not find files for the given pattern(s).
Brownie v1.16.4 - Python development framework for Ethereum

BrownieFundMeProject is the active project.

Running 'scripts\fund_and_withdraw.py::main'...
  File "C:\Python310\lib\site-packages\eth_brownie-1.16.4-py3.10.egg\brownie\_cli\run.py", line 49, in main
    return_value, frame = run(
  File "C:\Python310\lib\site-packages\eth_brownie-1.16.4-py3.10.egg\brownie\project\scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File ".\scripts\fund_and_withdraw.py", line 13, in main
    fund()
  File ".\scripts\fund_and_withdraw.py", line 8, in fund
    entrance_fee = fund_me.getVersion()
  File "C:\Python310\lib\site-packages\eth_brownie-1.16.4-py3.10.egg\brownie\network\multicall.py", line 115, in _proxy_call
    result = ContractCall.__call__(*args, **kwargs)  # type: ignore
  File "C:\Python310\lib\site-packages\eth_brownie-1.16.4-py3.10.egg\brownie\network\contract.py", line 1729, in __call__
    return self.call(*args, block_identifier=block_identifier)
  File "C:\Python310\lib\site-packages\eth_brownie-1.16.4-py3.10.egg\brownie\network\contract.py", line 1533, in call
    raise VirtualMachineError(e) from None
VirtualMachineError: revert

Thanks for any assistance!

Lesson 11, code verification on etherscan

Hi @PatrickAlphaC , I can't understand why in the video/repo, when you write the deploy script for AdvancedCollectible contract, you don't use something like:

publish_source=config["networks"][network.show_active()].get("verify", False)

while deploying the contract, then your code is verified on etherscan rinkeby in the video(I did my scripts following yours and mine is not getting verified)
Did I miss something?

pip install web3

Hello,

When I try to install web3 in VSCode, Iget the following error

"Microsoft Visual C++ 14.0 or greater is required. Get it with" and a link.

I downloaded visual studio but I am still getting the same error. Any ideas?

Thanks!

Lesson 7 : Error "Call the contract method without broadcasting a transaction."

Hello :D! , im struggling with this error , i dont know what is my fault

aa

This is how looks my project
aaa

And i added alchemy network like this:
brownie networks add development mainnet-fork cmd=ganache-cli host=http://127.0.0.1 fork=URL accounts=10 mnemonic=brownie port=8545

i downloaded the interface[AggregatorV3Interface] contract fom here npm install @chainlink/contracts --save

My solidity code:
aaaa

I stopped at 6:27:10 [Video] , im stuck :(

Another Issue with Brownie, please help, can't get it to run deploy.py

Lesson 5: when trying to get Brownie to run the deploy.py with print in it

When I run brownie run scripts/deploy.py

I get

INFO: Could not find files for the given pattern(s).
Brownie v1.17.1 - Python development framework for Ethereum

BrownieSimpleStorageProject is the active project.

Launching 'ganache-cli.cmd --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\_cli\__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\_cli\run.py", line 44, in main
    network.connect(CONFIG.argv["network"])
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\network\main.py", line 50, in connect
    rpc.launch(active["cmd"], **active["cmd_settings"])
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\network\rpc\__init__.py", line 75, in launch
    self.process = self.backend.launch(cmd, **kwargs)
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\network\rpc\ganache.py", line 73, in launch
    return psutil.Popen(cmd_list, stdin=DEVNULL, stdout=out, stderr=out)
  File "c:\python310\lib\site-packages\psutil-5.8.0-py3.10-win-amd64.egg\psutil\__init__.py", line 1312, in __init__
    self.__subproc = subprocess.Popen(*args, **kwargs)
  File "C:\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
Launching 'ganache-cli.cmd --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\_cli\__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\_cli\run.py", line 44, in main
    network.connect(CONFIG.argv["network"])
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\network\main.py", line 50, in connect
    rpc.launch(active["cmd"], **active["cmd_settings"])
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\network\rpc\__init__.py", line 75, in launch
    self.process = self.backend.launch(cmd, **kwargs)
  File "C:\Python310\lib\site-packages\eth_brownie-1.17.1-py3.10.egg\brownie\network\rpc\ganache.py", line 73, in launch
    return psutil.Popen(cmd_list, stdin=DEVNULL, stdout=out, stderr=out)
  File "c:\python310\lib\site-packages\psutil-5.8.0-py3.10-win-amd64.egg\psutil\__init__.py", line 1312, in __init__
    self.__subproc = subprocess.Popen(*args, **kwargs)
  File "C:\Python310\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python310\lib\subprocess.py", line 1435, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Cant Install Web3 with pip

Tried installing web3 as instructured but encountered the following issue:

$ python -m pip install web3
Requirement already satisfied: web3 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\web3-5.23.1-py3.10.egg (5.23.1)
Requirement already satisfied: aiohttp<4,>=3.7.4.post0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\aiohttp-3.7.4.post0-py3.10.egg (from web3) (3.7.4.post0)
Requirement already satisfied: eth-abi<3.0.0,>=2.0.0b6 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_abi-2.1.1-py3.10.egg (from web3) (2.1.1)
Requirement already satisfied: eth-account<0.6.0,>=0.5.5 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_account-0.5.5-py3.10.egg (from web3) (0.5.5)
Requirement already satisfied: eth-hash[pycryptodome]<1.0.0,>=0.2.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_hash-0.3.2-py3.10.egg (from web3) (0.3.2)
Requirement already satisfied: eth-typing<3.0.0,>=2.0.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_typing-2.2.2-py3.10.egg (from web3) (2.2.2)
Requirement already satisfied: eth-utils<2.0.0,>=1.9.5 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_utils-1.10.0-py3.10.egg (from web3) (1.10.0)
Requirement already satisfied: hexbytes<1.0.0,>=0.1.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\hexbytes-0.2.2-py3.10.egg (from web3) (0.2.2)
Requirement already satisfied: ipfshttpclient==0.8.0a2 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\ipfshttpclient-0.8.0a2-py3.10.egg (from web3) (0.8.0a2)
Requirement already satisfied: jsonschema<4.0.0,>=3.2.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\jsonschema-3.2.0-py3.10.egg (from web3) (3.2.0)
Requirement already satisfied: lru-dict<2.0.0,>=1.1.6 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\lru_dict-1.1.7-py3.10-win-amd64.egg (from web3) (1.1.7)
Requirement already satisfied: protobuf<4,>=3.10.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\protobuf-3.18.0-py3.10.egg (from web3) (3.18.0)
Collecting web3
Using cached web3-5.24.0-py3-none-any.whl (487 kB)
Using cached web3-5.23.0-py3-none-any.whl (485 kB)
Using cached web3-5.22.0-py3-none-any.whl (484 kB)
Using cached web3-5.21.0-py3-none-any.whl (482 kB)
Using cached web3-5.20.1-py3-none-any.whl (479 kB)
Using cached web3-5.20.0-py3-none-any.whl (480 kB)
Using cached web3-5.19.0-py3-none-any.whl (470 kB)
Collecting ipfshttpclient==0.7.0a1
Using cached ipfshttpclient-0.7.0a1-py3-none-any.whl (231 kB)
Collecting web3
Using cached web3-5.18.0-py3-none-any.whl (469 kB)
Using cached web3-5.17.0-py3-none-any.whl (469 kB)
Collecting pypiwin32>=223
Using cached pypiwin32-223-py3-none-any.whl (1.7 kB)
Requirement already satisfied: requests<3.0.0,>=2.16.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages (from web3) (2.26.0)
Collecting websockets<9.0.0,>=8.1.0
Using cached websockets-8.1.tar.gz (58 kB)
Requirement already satisfied: multiaddr>=0.0.7 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\multiaddr-0.0.9-py3.10.egg (from ipfshttpclient==0.7.0a1->web3) (0.0.9)
Requirement already satisfied: parsimonious<0.9.0,>=0.8.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\parsimonious-0.8.1-py3.10.egg (from eth-abi<3.0.0,>=2.0.0b6->web3) (0.8.1)
Requirement already satisfied: bitarray<1.3.0,>=1.2.1 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\bitarray-1.2.2-py3.10-win-amd64.egg (from eth-account<0.6.0,>=0.5.5->web3) (1.2.2)
Requirement already satisfied: eth-keyfile<0.6.0,>=0.5.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_keyfile-0.5.1-py3.10.egg (from eth-account<0.6.0,>=0.5.5->web3) (0.5.1)
Requirement already satisfied: eth-keys!=0.3.2,<0.4.0,>=0.2.1 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_keys-0.3.3-py3.10.egg (from eth-account<0.6.0,>=0.5.5->web3) (0.3.3)
Requirement already satisfied: eth-rlp<2,>=0.1.2 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\eth_rlp-0.2.1-py3.10.egg (from eth-account<0.6.0,>=0.5.5->web3) (0.2.1)
Requirement already satisfied: rlp<3,>=1.0.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\rlp-1.2.0-py3.10.egg (from eth-account<0.6.0,>=0.5.5->web3) (1.2.0)
Requirement already satisfied: pycryptodome<4,>=3.6.6 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\pycryptodome-3.10.1-py3.10-win-amd64.egg (from eth-hash[pycryptodome]<1.0.0,>=0.2.0->web3) (3.10.1)
Requirement already satisfied: cytoolz<1.0.0,>=0.9.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\cytoolz-0.11.0-py3.10-win-amd64.egg (from eth-keyfile<0.6.0,>=0.5.0->eth-account<0.6.0,>=0.5.5->web3) (0.11.0)
Requirement already satisfied: toolz>=0.8.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\toolz-0.11.1-py3.10.egg (from cytoolz<1.0.0,>=0.9.0->eth-keyfile<0.6.0,>=0.5.0->eth-account<0.6.0,>=0.5.5->web3) (0.11.1)
Requirement already satisfied: attrs>=17.4.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\attrs-21.2.0-py3.10.egg (from jsonschema<4.0.0,>=3.2.0->web3) (21.2.0)
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\pyrsistent-0.18.0-py3.10-win-amd64.egg (from jsonschema<4.0.0,>=3.2.0->web3) (0.18.0)
Requirement already satisfied: setuptools in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages (from jsonschema<4.0.0,>=3.2.0->web3) (57.4.0)
Requirement already satisfied: six>=1.11.0 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\six-1.16.0-py3.10.egg (from jsonschema<4.0.0,>=3.2.0->web3) (1.16.0)
Requirement already satisfied: base58 in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\base58-2.1.0-py3.10.egg (from multiaddr>=0.0.7->ipfshttpclient==0.7.0a1->web3) (2.1.0)
Requirement already satisfied: netaddr in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\netaddr-0.8.0-py3.10.egg (from multiaddr>=0.0.7->ipfshttpclient==0.7.0a1->web3) (0.8.0)
Requirement already satisfied: varint in c:\users\rjnee\appdata\local\programs\python\python310\lib\site-packages\varint-1.0.2-py3.10.egg (from multiaddr>=0.0.7->ipfshttpclient==0.7.0a1->web3) (1.0.2)
INFO: pip is looking at multiple versions of pycryptodome to determine which version is compatible with other requirements. This could take a while.
Collecting pycryptodome<4,>=3.6.6
Using cached pycryptodome-3.10.4-cp35-abi3-win_amd64.whl (1.8 MB)
Using cached pycryptodome-3.10.3-cp35-abi3-win_amd64.whl (1.8 MB)
Using cached pycryptodome-3.10.1-cp35-abi3-win_amd64.whl (1.6 MB)
Using cached pycryptodome-3.9.9.tar.gz (15.5 MB)
Using cached pycryptodome-3.9.8.tar.gz (15.6 MB)
Using cached pycryptodome-3.9.7.tar.gz (15.5 MB)
Using cached pycryptodome-3.9.6.tar.gz (15.5 MB)
INFO: pip is looking at multiple versions of pycryptodome to determine which version is compatible with other requirements. This could take a while.
Using cached pycryptodome-3.9.4.tar.gz (11.6 MB)
Using cached pycryptodome-3.9.3.tar.gz (11.6 MB)
Using cached pycryptodome-3.9.2.tar.gz (11.6 MB)
Using cached pycryptodome-3.9.1.tar.gz (11.6 MB)
Using cached pycryptodome-3.9.0.tar.gz (11.6 MB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
Using cached pycryptodome-3.8.2.tar.gz (12.4 MB)

Fundme.sol

Greetings,

The following change was necessary for a clean compilation of "FundMe.sol" download from github:

// pragma solidity >=0.6.6 <0.9.0;
pragma solidity >=0.6 <0.9.0;

and the "compiler 0.6.0+commit.26b70077" was needed for a successful compilation.

However, at deploy time (Injected Web3 and Rinkeby testnet):

Deploy Alert: "This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly"

Remix was run at 10:30PM 2021/Oct/11

Is there anything missing from the FundMe.sol?

Best regards,

phiho

Lesson 10, getting "SafeERC20: low-level call failed"

I really don't know what I am missing, I started with my own code, and got the error, then copy pasted your code and still got the error... is this the problem that you were hinting about using INFURA?

the stacktrace:

(venv) ➜  aave_interaction  brownie run scripts/borrow.py 
Brownie v1.16.3 - Python development framework for Ethereum

AaveInteractionProject is the active project.

Launching 'ganache-cli --accounts 10 --hardfork istanbul --fork https://mainnet.infura.io/v3/XXXXXXXXXXXXXXXXX --gasLimit 12000000 --mnemonic brownie --port 8545 --chainId 1'...

Running 'scripts/borrow.py::main'...
Transaction sent: 0x308eae45c4dcdc648c641c0e9bb566e677c1e549049b1222f8eac73f8a06c670
  Gas price: 0.0 gwei   Gas limit: 12000000   Nonce: 2
  IERC20.approve confirmed   Block: 13246390   Gas used: 43952 (0.37%)

  IERC20.approve confirmed   Block: 13246390   Gas used: 43952 (0.37%)

Transaction sent: 0xaa67184ce7177a78b2bb25390bdfef77301b032639454ab10fab2c58c29afbe1
  Gas price: 0.0 gwei   Gas limit: 12000000   Nonce: 3
  ILendingPool.deposit confirmed (SafeERC20: low-level call failed)   Block: 13246391   Gas used: 170922 (1.42%)

  File "brownie/_cli/run.py", line 49, in main
    return_value, frame = run(
  File "brownie/project/scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File "./scripts/borrow.py", line 42, in main
    borrow()
  File "./scripts/borrow.py", line 33, in borrow
    tx = lendingPool.deposit(
  File "brownie/network/contract.py", line 1693, in __call__
    return self.transact(*args)
  File "brownie/network/contract.py", line 1566, in transact
    return tx["from"].transfer(
  File "brownie/network/account.py", line 680, in transfer
    receipt._raise_if_reverted(exc)
  File "brownie/network/transaction.py", line 406, in _raise_if_reverted
    raise exc._with_attr(
VirtualMachineError: revert: SafeERC20: low-level call failed
Trace step 10228, program counter 1379:
  File "contracts/protocol/lendingpool/LendingPool.sol", line 445, in SafeERC20.callOptionalReturn:    
          );
        require(success, Errors.LP_LIQUIDATION_CALL_FAILED);
    
Terminating local RPC client...

and the borrow function is:

def borrow():
    # get LendingPool
    lendingPool = getLendingPool()
    weth_token = config["networks"][network.show_active()]["weth_token"]
    amount = 1e17
    account = getAccount()
    # approve move out ERC20
    approveERC20(
        weth_token, lendingPool.address, amount, account
    )

    # depositing
    tx = lendingPool.deposit(
        weth_token, amount, account.address, 0, {"from": account.address}
    )
    tx.wait(1)

def getLendingPool():
    return interface.ILendingPool(getLendingPoolProvider().getLendingPool())


def getLendingPoolProvider():
    return interface.ILendingPoolAddressesProvider(
        config["networks"][network.show_active()]["lending_pool_addr_provider"]
    )

UPDATE: it's not, I searched the moment in the video where you add the alchemy network, did everything and nothing changed... and the interfaces are copied from you

However, this is not happening in the kovan network

Can't use py-socl-x

Hi everyone

I'm having a problem with the soclx tool, if I try to run python deploy.py (at 3:44:36 of this course) I get an error that says:

solcx.exceptions.SolcNotInstalled: solc 0.6.0 has not been installed. Use solcx.install_solc('0.6.0') to install.

So at this point I run python on my vs code terminal but when executing the command I get a new error:

Traceback (most recent call last):
File "", line 1, in
NameError: name 'solcx' is not defined

Not only, every soclx command outputs the same error as above
I checked with pip list and the soclx tool is in the list, I have followed word by word all the instructions but I can't see what I've done wrong

Does anyone had the same issue and know ho to fix this? Thanks

no tests ran - Tests issue

This isn't urgent but ive randomly not been able to run tests in eth-brownie. I get this

Brownie v1.16.4 - Python development framework for Ethereum

=================================================================================================== test session starts ===================================================================================================
platform win32 -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: C:\Users\knot\Desktop\dev\brownie_fund_me
plugins: eth-brownie-1.16.4, hypothesis-6.21.6, forked-1.3.0, xdist-1.34.0, web3-5.23.1
collected 0 items

================================================================================================== no tests ran in 0.11s ==================================================================================================

I have the .py file in the /tests folder so not sure why it isnt picking it up. thank you

"Import Brownie could not be resolved"

Its basically the same problem with solcx a few days ago, but its not working with a virtual environment either.

So I copied every step from Patrick.

i installed pipx:
python3 -m pip install --user pipx

Then:
python3 -m pipx ensurepath

Then I've installed brownie and it works perfectly fine.

Bildschirmfoto 2021-09-18 um 11 29 41

I can even compile stuff, its working:

Bildschirmfoto 2021-09-18 um 11 33 22

Here comes the problem. "Import Brownie could not be resolved":
Bildschirmfoto 2021-09-18 um 11 41 32

Then I remembered, maybe I need a virtual environment. So deleted the folder brownie_simple_storage and started again from scratch.

mkdir brownie_simple_storage

Open the folder.

I created the virtual environment python3 -m venv tutorial-env activated it source tutorial-env/bin/activate after that I've installed everything on the virtual env, tried brownie init and it didn't work, it showed an Error.

To solve this I deleted the virtual environment tried brownie init again and then brownie worked.

So I did understand that brownie init must come first, after that comes the virtual environment, otherwise it won't work.

So after brownie init I create the virtual environment python3 -m venv venv after that I activate it source venv/bin/activate, so it look like this:

Bildschirmfoto 2021-09-18 um 12 52 22

After that I try to install python3 -m pip install --user pipx on the venv, it don't work, I take out the --user it works.

Then I do python3 -m pipx ensurepath, no error.

I do install eth-brownie successfully. I do have pipx and pip installed successfully.

pip list, pipx list:

Bildschirmfoto 2021-09-18 um 12 58 47

brownie --version, pip --version, pipx --version:

Bildschirmfoto 2021-09-18 um 13 06 32

Unfortunately its still not working, can't import from Brownie. I have a guess that maybe somethings wrong with the Path.

I know its a really long Issue, but I wanted to show every detail.

I would be really thankful if somebody could help me out.

Receive function value to the frontend

Hi i am using useContractCall() to receive a function call from the smart contract. I tried it with a simple function that only returns a uint256 number but it still returns undefined. I want to use it so i can see how much is being staked by the user.

SmartContractLottery players array is pre-filled with random accounts

Hi all, I have an issue with the test_can_pick_winner integration test, it fails because when the test asserts the winner the account is not the same, this seemed a bit strange so I created additional events in the contract to see what the players array looked the moment of the assert, 2 accounts (both 0x000000000000000.. like) are present but I have no idea how they got there because there are only 2 transactions to the enter function in the code I wrote and they are made with my account, I created another event to catch all the entering players and indeed it detects the correct entries made in the code

So what could be going on here? I'm really confused

image attached for better context
wtf

Lesson 11 error while importing contracts from browine

In lesson 11 (before 10:47:15) when I try to run my deploy_and_create.py(for the advanced_collectible) I get this error where I can't import mocks from brownie

image

I can't understand what I'm missing, can someone help me pls?

lesson 1 issue

I keep getting this whenever I press the people button after I deploy the code looks good. This is after coding the array where you have four buttons showing addperson, store, people and retrieve.

[call] from: 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4to: SimpleStorage.people(uint256)data: 0x9e7...00000
call to SimpleStorage.people errored: VM error: invalid opcode.

invalid opcode

The execution might have thrown.

Debug the transaction to get more information.

error in code

Brownie throws RPCRequestError: Web3 is not connected. after test

Hello

After testing the "test_can_start_and_enter_lottery" the local RPC client termination starts but I get this error (log below), I can't understand what is causing this, every other test does not get this error, can someone explain me how to fix this and what gives this error?
Thanks

ERROR LOG:

PS D:\SolidityProjects\SmartContractLottery> brownie test -k test_can_start_and_enter_lottery
INFORMAZIONI: impossibile trovare file corrispondenti ai
criteri di ricerca indicati.
Brownie v1.16.4 - Python development framework for Ethereum

========================================================================================================== test session starts ===========================================================================================================
platform win32 -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: D:\SolidityProjects\SmartContractLottery
plugins: eth-brownie-1.16.4, hypothesis-6.21.6, forked-1.3.0, xdist-1.34.0, web3-5.23.1
collected 3 items / 2 deselected / 1 selected

Launching 'ganache-cli.cmd --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...

tests\test_lottery_unit.py . [100%]

==================================================================================================== 1 passed, 2 deselected in 7.27s =====================================================================================================
Terminating local RPC client...
Exception in thread Thread-16:
Traceback (most recent call last):
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection
raise err
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:\Users\Fedro\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1279, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Fedro\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1325, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Fedro\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1274, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Fedro\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1034, in _send_output
self.send(msg)
File "C:\Users\Fedro\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 974, in send
self.connect()
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connection.py", line 200, in connect
conn = self._new_conn()
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001DCED7A8A00>: Failed to establish a new connection: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=8545): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001DCED7A8A00>: Failed to establish a
new connection: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\rpc\ganache.py", line 82, in _request
response = web3.provider.make_request(method, args) # type: ignore
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\web3\providers\rpc.py", line 88, in make_request
raw_response = make_post_request(
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\web3_utils\request.py", line 48, in make_post_request
response = session.post(endpoint_uri, data=data, *args, **kwargs) # type: ignore
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\requests\sessions.py", line 590, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\requests\adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8545): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001DCED7A8A00>: Failed to establish a new connection: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Fedro\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Users\Fedro\AppData\Local\Programs\Python\Python39\lib\threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\state.py", line 331, in add_to_undo_buffer
self.sleep(0)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\state.py", line 374, in sleep
self.time_offset = int(rpc.Rpc().sleep(seconds))
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\rpc_init
.py", line 45, in wrapped
return fn(*args, **kwargs)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\rpc_init
.py", line 167, in sleep
return self.backend.sleep(seconds)
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\rpc\ganache.py", line 91, in sleep
return _request("evm_increaseTime", [seconds])
File "C:\Users\Fedro.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\rpc\ganache.py", line 86, in _request
raise RPCRequestError("Web3 is not connected.")
brownie.exceptions.RPCRequestError: Web3 is not connected.

Brownie is not detecting the GUI

Title, course at 5:37:??, it does start the ganache-cli as usual tho, so there is no errors in deploying contracts and mocks but I don't understand why it behaves like this.

I can attach a video of the problem if needed

Fatal Error in Launcher when Checking Pip Version in VSCode

Trying to check pip version in VSCode terminal and I get the following error. I entered in Bash Terminal. Encountered when following along with the tutorial at around 3:37:00.

$ pip --version
Fatal error in launcher: Unable to create process using '"C:\Python39\python.exe" "C:\Python39\Scripts\pip.exe" --version': The system
cannot find the file specified.

solc 0.6.0 has not been installed. Use solcx.install_solc('0.6.0') to install.

Hello, newb here - in Visual Studio Code I am attempting to use Python to compile my solidity code (SimpleStorage.sol). When I issue the command 'python deploy.py' I get the following error:

Traceback (most recent call last):
File "D:\Documents\Projects\BlockChain\web3_py_simple_storage\deploy.py", line 9, in
compiled_sol = compile_standard(
File "C:\Python39\lib\site-packages\solcx\main.py", line 368, in compile_standard
solc_binary = get_executable(solc_version)
File "C:\Python39\lib\site-packages\solcx\install.py", line 194, in get_executable
raise SolcNotInstalled(
solcx.exceptions.SolcNotInstalled: solc 0.6.0 has not been installed. Use solcx.install_solc('0.6.0') to install.

And this is my deploy.py:

`from solcx import compile_standard

with open("./SimpleStorage.sol", "r") as file:
simple_storage_file = file.read()
print(simple_storage_file)

Compile our Solidity

compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
"settings": {
"outputSelection": {
"": {"": ["abi", "metadata", "evm.bytecode", "evm.sourcemap"]}
}
},
},
solc_version="0.6.0",
)
print(compiled_sol)`

I have double checked that in Visual Studio Code that the 'workspace compiler version' is set to 'Remote' (as is global actually). I have Python 3.9.7 installed, along with the Solidity extension (v0.0.125). What am I missing?

Lesson 4 - ImportError: No Module named solcx

Hello! I'm having some issues when trying to run "python deploy.py" at exactly the 3:44:49 mark in the course! Here is a copy of my code in VScode:

from solcx import compile_standard, install_solc

install_solc("0.6.0")

with open("./SimpleStorage.sol", "r") as file:
simple_storage_file = file.read()

compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
"settings": {
"outputSelection": {
"": {"": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
}
},
},
solc_version="0.6.0",
)

When I type "python deploy.py" into the terminal of VScode, I get this response in the terminal window:

Traceback (most recent call last):
File "deploy.py", line 1, in
import solcx
ImportError: No module named solcx"

I have installed solcx already, as well. When I try the pip install py-solc-x command in terminal I get this response in the terminal window:

"Requirement already satisfied: py-solc-x in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (1.1.0)
Requirement already satisfied: semantic-version<3,>=2.8.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from py-solc-x) (2.8.5)
Requirement already satisfied: requests<3,>=2.19.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from py-solc-x) (2.26.0)
Requirement already satisfied: charset-normalizer~=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.19.0->py-solc-x) (2.0.6)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.19.0->py-solc-x) (1.26.7)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.19.0->py-solc-x) (2021.5.30)
Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests<3,>=2.19.0->py-solc-x) (3.2)"

Just trying to figure out how to proceed from here!
Thanks for taking the time to help!

Stuck at installing Brownie

Hi!

I'm stuck at installing eth-brownie (python 3.10)

pip failed to build package:
cytoolz

Some possibly relevant errors from pip install:
cytoolz/functoolz.c:23087:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
cytoolz/functoolz.c:23092:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
cytoolz/functoolz.c:23176:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
error: command '/usr/bin/clang' failed with exit code 1

In the error log there's also
ALERT: Cython not installed. Building without Cython.

But cython is installed: Cython version 0.29.24

Any suggestions?
Thanks!

Lesson 8 - endLottery not working correctly

This is less an issue and more of a heads-up.
At the end of Lesson 8 when we do the integration test of endLottery, it constantly failed for me, due to the recentWinner being 0x000... and the assert expecting the account address.
It seems like a 60-second sleep is sometimes not enough to get the random number on the rinkeby network. Increasing the sleep to 120 fixed the error.

Brownie installation on macOS failing

I tried to install brownie using pipx but it failed on macOS. Then I installed using using pip install eth-brownie. Installation seems to be successful however when I start brownie I get below error. Please note I am using a M1 mac.

ImportError: dlopen(/Users/sabbir/Solidity/smart_contract_venv/lib/python3.8/site-packages/regex/_regex.cpython-38-darwin.so, 0x0002): tried: '/Users/sabbir/Solidity/smart_contract_venv/lib/python3.8/site-packages/regex/_regex.cpython-38-darwin.so' (code signature in <999D73A8-1E7A-391A-B219-191ECB5B4270> '/Users/sabbir/Solidity/smart_contract_venv/lib/python3.8/site-packages/regex/_regex.cpython-38-darwin.so' not valid for use in process: Trying to load an unsigned library), '/usr/local/lib/_regex.cpython-38-darwin.so' (no such file), '/usr/lib/_regex.cpython-38-darwin.so' (no such file)

Lesson 6 (Brownie FundMe) - Able to deploy to mainnet fork without insufficient funds error

For some reason at minute 5:57:26 I don’t get an insufficient funds error when deploying FundMe.sol to mainnet-fork.

Instead the transaction is successful and the contract is deployed. Similarly, I don't get an index error when running accounts[0] in minute 5:59:00.

This is the full console output:

➜  brownie_fund_me brownie run scripts/deploy.py --network mainnet-fork
Brownie v1.17.0 - Python development framework for Ethereum

BrownieFundMeProject is the active project.

Launching 'ganache-cli --accounts 10 --hardfork istanbul --fork https://mainnet.infura.io/v3/bd9a329c67044086b423de53c96e5584 --gasLimit 12000000 --mnemonic brownie --port 8545 --chainId 1'...

Running 'scripts/deploy.py::main'...
Account address is: 0x66aB6D9362d4F35596279692F0251Db635165871
The active network is mainnet-fork.
Transaction sent: 0xa8ae8aac193c57a6709bd9fffa43247648ba15ea3a70fb5d11eb9ad25ec7ab44
  Gas price: 0.0 gwei   Gas limit: 12000000   Nonce: 2
  FundMe.constructor confirmed   Block: 13524986   Gas used: 405169 (3.38%)
  FundMe deployed at: 0xE7eD6747FaC5360f88a2EFC03E00d25789F69291

Contract deployed to 0xE7eD6747FaC5360f88a2EFC03E00d25789F69291
Terminating local RPC client...

And this is my brownie-config.yaml file:

dependencies:
  # - <organization/repo>@<version>
  - smartcontractkit/[email protected]
compiler:
  solc:
    remappings:
      - '@chainlink=smartcontractkit/[email protected]'
dotenv: .env
networks:
  default: development
  rinkeby:
    eth_usd_price_feed: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'
    verify: True
  mainnet-fork:
    eth_usd_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
    verify: False
  development:
    verify: False
  ganache-local:
    verify: False
wallets:
  from_key: ${PRIVATE_KEY}

Additionally, these are my listed networks on brownie:

➜  brownie_fund_me brownie networks list
Brownie v1.17.0 - Python development framework for Ethereum

The following networks are declared:

Ethereum
  ├─Mainnet (Infura): mainnet
  ├─Ropsten (Infura): ropsten
  ├─Rinkeby (Infura): rinkeby
  ├─Goerli (Infura): goerli
  ├─Kovan (Infura): kovan
  └─ganache-local: ganache-local

Ethereum Classic
  ├─Mainnet: etc
  └─Kotti: kotti

Arbitrum
  └─Mainnet: arbitrum-main

Binance Smart Chain
  ├─Testnet: bsc-test
  └─Mainnet: bsc-main

Fantom Opera
  ├─Testnet: ftm-test
  └─Mainnet: ftm-main

Harmony
  └─Mainnet (Shard 0): harmony-main

Polygon
  ├─Mainnet (Infura): polygon-main
  └─Mumbai Testnet (Infura): polygon-test

XDai
  ├─Mainnet: xdai-main
  └─Testnet: xdai-test

Development
  ├─Ganache-CLI: development
  ├─Geth Dev: geth-dev
  ├─Hardhat: hardhat
  ├─Hardhat (Mainnet Fork): hardhat-fork
  ├─Ganache-CLI (Mainnet Fork): mainnet-fork
  ├─Ganache-CLI (BSC-Mainnet Fork): bsc-main-fork
  ├─Ganache-CLI (FTM-Mainnet Fork): ftm-main-fork
  ├─Ganache-CLI (Polygon-Mainnet Fork): polygon-main-fork
  └─Ganache-CLI (XDai-Mainnet Fork): xdai-main-fork

One thing I've noticed is that if I run:

brownie console --network mainnet-fork

And then I try this, I get an actual account object:

accounts[0]
<Account '0x66aB6D9362d4F35596279692F0251Db635165871'>

I was wondering whether brownie is now perhaps able to do these tutorial steps by itself when first deploying to a mainnet fork (create an account with funds) but it doesn't look like it judging from their releases page:
https://github.com/eth-brownie/brownie/releases

Another theory is whether this is somehow handled by Infura, which I'm not still very familiar with.

Can't install web3

Hi, I try to install web3 but an error is accuring whatever the solution I try, I did a lot of searching in the net and the near issue that like to mine consiste as solution to install visuel studio build tools, but it didn't work with me, bellow you can see the error.

ERROR: Command errored out with exit status 1:
     command: 'c:\python39\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\pc\\AppData\\Local\\Temp\\pip-install-uusfbzla\\varint_767bca6b5fd04b2eb5ebc4420507b387\\setup.py'"'"'; 
__file__='"'"'C:\\Users\\pc\\AppData\\Local\\Temp\\pip-install-uusfbzla\\varint_767bca6b5fd04b2eb5ebc4420507b387\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\pc\AppData\Local\Temp\pip-record-3m2pw_cn\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\python39\Include\varint'
         cwd: C:\Users\pc\AppData\Local\Temp\pip-install-uusfbzla\varint_767bca6b5fd04b2eb5ebc4420507b387\     
    Complete output (9 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib
    copying varint.py -> build\lib
    running install_lib
    byte-compiling c:\python39\Lib\site-packages\varint.py to varint.cpython-39.pyc
    error: [Errno 13] Permission denied: 'c:\\python39\\Lib\\site-packages\\__pycache__\\varint.cpython-39.pyc.1328308953584'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python39\python.exe' -u -c 'import io, os, sys, setuptools, 
tokenize; sys.argv[0] = '"'"'C:\\Users\\pc\\AppData\\Local\\Temp\\pip-install-uusfbzla\\varint_767bca6b5fd04b2eb5ebc4420507b387\\setup.py'"'"'; __file__='"'"'C:\\Users\\pc\\AppData\\Local\\Temp\\pip-install-uusfbzla\\varint_767bca6b5fd04b2eb5ebc4420507b387\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\pc\AppData\Local\Temp\pip-record-3m2pw_cn\install-record.txt' --single-version-externally-managed --compile

Can any one help me please.

"Import solcx could not be resolved"

I have a very annoying problem. I can't import from solcx although I have installed it, when I do pip3 list it even shows solc and solcx as packages in the list.
Bildschirmfoto 2021-09-15 um 11 37 37

I have installed Python correctly. When I type python3 --version it shows Python 3.9.7

I have installed pip correctly. When I type pip --version it shows pip 18.1 from /Library/Python/2.7/site-packages/pip (python 2.7)

I have also installed pip3. When I type pip3 --version it shows pip 21.2.4 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

I have installed py-solc-x. When I install it, it shows that:

Bildschirmfoto 2021-09-15 um 11 44 40

Despite all that, it don't want to import it.

Bildschirmfoto 2021-09-15 um 11 42 00

I try since 2 days to solve this problem. I did almost everything. I am new to Python and the Chainlink Developer was right, installing these things is the hardest.
I would be really thankful if somebody could help me out.

code does not deploy because of brownie-config file

I got the folliwing message deploying deploy.py in brownie_simple_storage:
ScannerError: mapping values are not allowed here
in "C:\Users\Demo\brownie_simple_storage\brownie-config.yaml", line 2, column 8
it is a colon after the wallets:
wallets:

What is the problem?

TypeError: from field must match key's 0x1973268d75BaFcf21C6D2dFF604a0d64d0158E50, but it was 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1

I get this error i do not know what is happening please help me out with this problem
from solcx import compile_standard, install_solc
import json
from web3 import Web3
import os

with open("./SimpleStorage.sol") as file:
simple_storage_file = file.read()
print(simple_storage_file)

Compile our solidity code

install_solc("0.6.0")
compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
"settings": {
"outputSelection": {
"": {"": ["abi", "metadata", "evm.bytecode", "evnm.sourceMap"]}
}
},
},
solc_version="0.6.0",
)
with open("compiled_code.json", "w") as file:
json.dump(compiled_sol, file)

get bytecode

bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["evm"][
"bytecode"
]["object"]

get abi

abi = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]

for connecting to ganache

w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
chain_id = 1337
my_address = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"
private_key = os.getenv("PRIVATE_KEY")

Create our first contract

SimpleStorage = w3.eth.contract(abi=abi, bytecode=bytecode)

Getting the transaction counts

nonce = w3.eth.getTransactionCount(my_address)

Build a transaction

transaction = SimpleStorage.constructor().buildTransaction(
{"chainId": chain_id, "from": my_address, "nonce": nonce}
)

Sign a transaction

signed_txn = w3.eth.account.sign_transaction(transaction, private_key=private_key)
print("Deploying...")

Send a transaction

send_txn = w3.eth.send_raw_transaction(signed_txn.rawTransaction)
txn_receipt = w3.eth.get_transaction_receipt(send_txn)
print("Deployed")

Working with contracts

Addresses

ABI

simple_storage = w3.eth.contract(address=txn_receipt.contractAddress, abi=abi)
print(simple_storage.functions.retrieve().call())

store_txn = simple_storage.functions.store(15).buildTransaction(
{"chainId": chain_id, "from": my_address, "nonce": nonce + 1}
)

store_signed_txn = w3.eth.account.sign_transaction(store_txn, private_key=private_key)
print("Updating")
send_store_txn = w3.eth.send_raw_transaction(store_signed_txn.rawTransaction)
receipt_store_txn = w3.eth.get_transaction_receipt(send_store_txn)
print("Updated")
print(simple_storage.functions.retrieve().call())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.