# Crypto Gang Sessions
## Crypto Gang Session 2
Hey guys!
### Steps to setup
1. Open this site https://ethers.pro
2. Right click there
3. Select: `Inspect Element`
4. Go to `Console` tab
5. Try writing `1 + 1` and hit enter. It should print `2` in the next line
Note in case of firefox you have to add to console `"allow pasting"`
### Setps to get private key from Metamask
1. Open metamask and enter password
2. 3 vertical dots click on it in top right
3. `Account Details`
4. `Export private key`
5. Copy paste it in console in the following manner
```ts
// Note there should be "0x" in starting and also inverted qommas
pk = '0xc8c33ae192ab75269c4f1bc...3ca008752145cf7aceea'
```
### Wallet
```ts
wallet = new ethers.Wallet(pk)
```
Note `W` should be capital and dont miss the `new` keyword
### Provider
```ts
provider = new ethers.providers.StaticJsonRpcProvider('https://goerli.infura.io/v3/1ef57e8f2b3a474fb2661e6eae4ebaf6');
```
#### Fetch blocknumber from the blockchain node
```ts
await provider.getBlockNumber()
```
#### Fetch balance of an account
```ts
await provider.getBalance(wallet.address)
ethers.utils.formatEther('0x0d2448c06fb99200')
```
#### Making a transaction
Create a tx object
```ts
tx = {
to: '0x4b140aCe91fA004937cB6581d04511Ab6D32568E',
value: ethers.utils.parseEther('0.1'),
nonce: provider.getTransactionCount(wallet.address),
gasLimit: 30000,
gasPrice: ethers.utils.parseUnits('1', 'gwei')
}
```
Sign the tx
```ts
await wallet.signTransaction(tx)
```
Copy the output of previous operation in below
```ts
await provider.sendTransaction('0xf86b03843b9aca00827530944b140ace91fa004937cb6581d04511ab6d32568e88016345785d8a0000801ca01e8bc9e9d2e599337ab630bb52a29a165f36364eaf45e58bd176a8327ceceb3ca02178db81c20a564fcaebbe9a19f1ac428d6096150b74e6390ce4ecffbb01e22e')
```
Etherscan transactions page: https://goerli.etherscan.io/address/0x4b140aCe91fA004937cB6581d04511Ab6D32568E
## Crypto Gang Session 3
Hi guys
crypto sesion: https://zoom.us/j/5903813567?pwd=Tlc5WldmZFZzeDNwN3daR0dpS3ptUT09
REMIX IDE: https://remix.ethereum.org/
Open in chrome
Create a new file "YourName.sol" inside `contracts` directory
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/ERC20.sol";
contract ZemseToken is ERC20 {
constructor() ERC20("ZemseToken", "ZT") {
_mint(msg.sender, 100 * 10**18);
}
}
```
Then compile your contract using Solidity compiler in left pane.
### Now deploying the contract
Metamask should be active, selected network "Goerli", and some non zero balance of ETH should be there.
In enviornment select "Injected Web3", and deploy contract.
Your goerli etherscan address page: https://goerli.etherscan.io/
### Add token to metamask
Select `Add token`
Select `Custom token` tab
Paste the contract address
Select next
## Session 4
- Solidity language (https://solidity-by-example.org, http://remix.ethereum.org)
- JavaScript (http://javascript.info)
- ERC20 token creation (we did this in last crypto session)
- What is an AMM exchange
- Uniswap V2 working
- What is DAO. Names of some live DAOs.
- Compound protocol (decentralised lending and borrowing)
#### Demos
1. Uniswap Demo
2. Aave Demo (similar to Compound)