Tag: Blockchain

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/

Blockchain Concepts

Advantages of Blockchain-

  • Decentralised – Having no single point of authority
  • Transperancy and Flexibility
  • Speed and Effeciency
  • Security and Immutability
  • Removal of counterparty risk
  • Trust minimised agreements
  • Hybrid smart conrtract with Chain Link (Oracle)

Terms and Abbrevations used in Blockchain-

DAO’s – Decentralised Autonomous Organization’s

Testnet – are free and for testing smart contracts

Mainnet – cost money and are considered “live”

Faucet – is and application that gives us free test token, like free test Rinkeby Ethereum

Block Explorer – an application that allows us to “view” transactions that happen on a blockchain.

Gas – is a unit of computational measure. The more computation a transaction uses the more “gas” you have to pay for.

Every transaction that happens on-chain pays a “gas fee” to node operators.

The amount of “gas” used and how much you pay depends on how “computationally expensive” your transaction is.

Sending ETH to 1 address would be “cheaper” than sending ETH to 1,000 addresses.

Gwei (giga-wei) – denomination or a small unit of Ether 1 Ether is 1 billion Gwei. It is used to measure cost of transaction i.e. used in the Ethereum network to but and sell goods and services.

Gas – Measure of computation use

Gas Price – How much it costs per unit of gas.

Gas Limit – Max amount of gas in a transaction

Transaction Fee – Gas used X Gas Price i.e. 21,000 gas @ 1GWEI per gas =21,000 GWEI

Gas Price of Ehtereum fluctuates based on the demand of the blockchain. More perople using or want to make transactions, the higher the gas price and therefore the higher the transaction fees.

Gnesis Block – First block in a blockchain

Hash – Unique fixed length string to identify a piece of data

Hash Algorithm – A function or algorithm that computes data into a unique hash.

Mining – The precess of finding the “solution” to the blockchain “problem”. Node get paid for mining blocks.

Block – A list of transactions mined together

Nonce – A “number used once” to find the “solution” to the blockchain problem. It’s also used to define the transaction number for an account/address.

Public Key – Is derived from your private key. Anyone can “see” it, and user it, and user it to verify that a transaction came from you.

Private key – Only know to the keyholder, its used to “sign” transactions.

Elliptic Curve Digital Signature Algorithm (ECDSA) – generates public key using private key.

Signing Transactions – A “one way” process. Someone with a private key signs a transaction by their private key being hashed with their transaction data. Anyone can then verify this new transaction hash with your public key.

Node: Single instance in a decentralized network. Anyone can join the network. Blockchains are resilient. Blockchain nodes keep lists of the transactions that occur. They are immutable- nothing can corrupt them.

Consensus – is the mechanism used to agree on the state of a blockchain.

Broken into 2 :-

— Chain Selection

Sybil Resistance – Proof of work. Block Author, defends on fake blockchains

— — PoW – Minners. Uses lot of electricity and is hence costly.

-Transaction Fees and Block Reward.- compete each other to find the answer to the problems. Whoever finds first get the transaction fees.

Sybil Attack – creates fake accounts to influence the network

51% attack

Longest Chain Rule

– — PoS — Validators – nodes put up collateral as a sybil resistance mechanism. Uses less energy. Slightly less decentralised.

ABI– ApplicationBinary Interface- tells Solidity how it can interact with another contract. What functions can be called from the contract. Interfaces compile down to ABI.