Category: Solidity

Solidity deployment error – ContractNotFound: No contract deployed at address

At time when the Ganache tool is re-opened all the Transactions and Constracts are reset. Whilst deploying contract you might see the error –

ContractNotFound: No contract deployed at {address}

PS C:\Projects\Blockchain\Solidity\brownie_fundme> brownie run .\scripts\deploy.py --network ganache-local
INFO: Could not find files for the given pattern(s).
Brownie v1.19.0 - Python development framework for Ethereum

BrownieFundmeProject is the active project.
  File "C:\Users\sandeep\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\_cli\__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "C:\Users\sandeep\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\_cli\run.py", line 45, in main
    network.connect(CONFIG.argv["network"])
  File "C:\Users\sandeep\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\main.py", line 55, in connect
    p._load_deployments()
  File "C:\Users\sandeep\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\main.py", line 370, in _load_deployments
    contract = ProjectContract(self, build, build_json.stem)
  File "C:\Users\sandeep\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1305, in __init__
    _DeployedContractBase.__init__(self, address, owner, tx)
  File "C:\Users\sandeep\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 708, in __init__
    raise ContractNotFound(f"No contract deployed at {address}")
ContractNotFound: No contract deployed at 0x7465E5ca8aFeFba39eFD83bd056ACAafa3d16646

Solution-

Delete all the files and folders in Deployment folder as closing the Ganache tool will reset contracts etc. the deployment folder has references to old contract.

Reference-

https://stackoverflow.com/questions/68460396/contractnotfound-no-contract-deployed-at

Add new network in Ganache using brownie for Ethereum Smart Contract local development

This should show the list of networks available in Brownie.

brownie networks list

In the Ethereum (persistent network) there is no Ganache(local) network

Add a network to Ethereum

brownie networks add Ethereum ganache-local host=http://127.0.0.1:7545 chainid=1337

Name of the network- ganache-local

host- where ganache endpoint is listening i.e. RPC Server

chainid – for ganache it is 1337

Output

Install Ganache for Solidity development

Ganache is the development tool used to run local blockchain for Ethereum development.

Ganache can be used to deploy the contract to local Blockchain. Its a simutated environemnt like Javascript VM when developing on Remix. It helps spin up a local Blockchain.

Ganache UI

Install the Ganache from following location-

https://trufflesuite.com/ganache/

Click the QUICKSTART to get started with Ethereum. By default Ethereum is selected. Ganache can also be used for Corda development

The next screen shows the local Blockchain with the Accounts having 100 ETH and ready to receive the contracts and transactions.

Options in Ganache in later post.

Ganache CLI-

Similar to Ganache UI the local Blockchain node can be setup using CLI.

Install nodejs – https://nodejs.org/en/download/

Check the version of node js

node -v

Install yarn

npm install --global yarn

Install Ganache CLI

yarn global add ganache-cli

Verify installation by checking the version

ganache-cli --version
Ganache CLI v6.12.2 (ganache-core: 2.13.2)

Use following command to see the Accounts, Transactions, Contracts etc in command line same as UI.

ganache-cli --deterministic

For more CLI options see –

https://www.npmjs.com/package/ganache-cli

Start deploying Contracts, signing and sending transactions to the local Blockchain.

To use Blockchain as a service use-

https://infura.io/

https://www.alchemy.com/