Last active
June 4, 2023 12:14
-
-
Save gwenf/41bddea8bbb71ae5317ecb5309399f52 to your computer and use it in GitHub Desktop.
Talk Outline for Python Web Conf 2022
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Github Repos | |
- Build a Blockchain: https://github.com/gwenf/build-a-blockchain | |
- Web3 Code (will be pushed during talk): https://github.com/gwenf/web3-py-blockchain-demo | |
- Merkle Tree Demo: https://github.com/dlom123/merkle | |
## Applications | |
- Metamask (Browser Plugin): https://metamask.io/ | |
- Ganache: https://trufflesuite.com/ganache/index.html | |
- For Mac, install Ganache with Homebrew: `brew install --cask ganache` | |
## Links | |
- Anders Blockchain Demo: https://andersbrownworth.com/blockchain/hash | |
- Remix Editor: https://remix.ethereum.org/ | |
- Rinkeby Block Explorer: https://rinkeby.etherscan.io/ | |
- Web3.py: https://web3py.readthedocs.io/en/stable/overview.html | |
- Eth Brownie: https://eth-brownie.readthedocs.io/en/stable/index.html | |
- Faucet for test Ether on Rinkeby: https://faucets.chain.link/rinkeby | |
- Safe Math: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol | |
## Build a Blockchain | |
### Step 1 - Create a Block | |
1. Create the Block | |
1. Create a Transaction | |
1. Populate the Block with Transactions | |
### Step 2 - Chain the Blocks Together | |
1. Create Blocks from Transactions | |
1. Append Blocks to a "Chain" (list) | |
### Step 3 - Enforce Integrity with Cryptography | |
1. Hash each block | |
1. Reference each block's hash in its subsequent block | |
### Step 4 - Create Nodes | |
1. Nodes should stay in sync | |
### Step 5 - Validation | |
1. Every account has an address (a public key) | |
2. Transactions can be sent and received between accounts | |
3. Transactions need to be signed and validated with public-private key pairs | |
4. Can submit transactions to ledger | |
### Step 6 - Mining | |
1. Proof of work (or proof of stake) | |
1. Mining rewards | |
### Step 7 - Consensus | |
1. Longest chain rule | |
## Web3.py | |
### Setup | |
- Install Ganache GUI | |
- Install Metamask (browser plugin) | |
- Create new Python project (a new folder with a virtual environment) | |
- Install python dependencies: `poetry add web3 py-solc-x python-dotenv` | |
### Step 1 - Interact with Local Blockchain | |
1. Connect to the local Ganache blockchain | |
2. Interact with accounts | |
3. Send and receive transactions | |
### Step 2 - Learn Browser Tooling & Solidity Overview | |
1. Test out a contract in the Remix online editor | |
2. Connect it to Metamask | |
3. Deploy that contract to Rinkeby | |
### Step 3 - Deploy a Contract | |
1. Test out a contract in the Remix online editor | |
2. Connect it to Metamask | |
3. Deploy that contract locally to the Ganache blockchain | |
4. Interact with the contract | |
### Step 4 - Connect to a live, deployed contract | |
1. Sign up for an account with Alchemy: https://www.alchemy.com/ | |
2. Copy URL with your key and use it with web3.py | |
3. Try out connecting to the Crypto Kitty contracts! | |
## Brownie | |
### Setup | |
- Install Ganache-CLI: `npm install -g ganache-cli` (make sure you are using Node version 16 first; if you need to change Node versions, you should use `nvm`) | |
- Check Ganache-CLI: `ganache-cli` | |
- Create a new folder & virtual environment | |
- Install Brownie: `pip install eth-brownie` | |
### Step 1 | |
1. Create a new Brownie project: `brownie init` | |
2. Add our contracts in constracts folder | |
3. Create `brownie-config.yaml` | |
4. `brownie compile` | |
1. `brownie pm install OpenZeppelin/openzeppelin-contracts@3.0.0` | |
5. Set up accounts & variables | |
### Step 2 | |
1. Write a script to deploy the contract | |
2. Interact with the contract | |
3. `brownie console` | |
1. `accounts[1].balance()` | |
2. `accounts[0].transfer(accounts[1], "10 ether")` | |
### Step 3 | |
1. Switch between test networks | |
2. `brownie networks list` | |
3. `brownie run scripts/deploy.py --network rinkeby` | |
4. Check the deployment of the contract on rinkeby's etherscan | |
### Step 4 | |
1. Test the contract with Pytest: `brownie test` | |
2. Code coverage | |
1. `brownie test --coverage` | |
2. `brownie gui` | |
### Step 5 - Brownie Mixes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment