Coder Social home page Coder Social logo

learning_solidity's Introduction

Learnign Blockchain and Web 3.0

This repository is a part of learning Solidity, and Blockchain.

I will keep updating this repo as I learn new topics or found any useful links that helped me learning.

Useful links:
how blockchain works under the hood

What is Proof of Work: explained

What is Proof of Stack

Byzantine Generals Problem (Consensus mechanism in BTC)

Solidity, Blockchian and Smart contract course

Working with Brownie

Initialize a new project

To initialize a new project use

brownie init

Run Scripts

brownie run <name of script file>

Import random accounts

from brownie import accounts

def deploy_contract():
    account =  accounts[0]

This will spin a local ganache cli and get 10 random accounts

Import local accounts

Run this command to add new account by entering private key

$ brownie accounts new <name_of_new_account>

it will ask to enter new private key, go to your wallet and past the private key

from brownie import accounts

def deploy_contract():
    account =  accounts.load("name_of_new_account")

This import your own account

Access contract in Brownie

We can directly access our Contract inside our deploy.py script file. Brownie will take care of reading and compiling the contract.

using .deploy({"from": <sender account>) will create a trasaction from provided account and deploy it to ganache local chain

Writing test for Contracts

Writing test is crutial for developing smart contracts, it saves lots of efforts to debug if the contracts are working as expected or not. We are using pytest for testing our smart contracts. Brownie provides same utilities as pytest using it under the hood.

We follow these steps when writing a test

  • Arrange: arrange all pieces of test
  • Act: create contract calls or other runtime work
  • Assert: assert the result of actions to the expected output

Brownie Console

For testing our contracts, we can use Brownie shell to access our contract without manually deploying it

Verify deployed Contracts

To verify deployed contracts progammatically you need to get access to api key from etherscan. Create an account and add you project to get one.

Add the api key to .env as ETHERSCAN_TOKENThen inside deploy() function add publish_source=TRUE

learning_solidity's People

Contributors

taimoorkhan1122 avatar

Stargazers

 avatar

Watchers

 avatar

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.