Блокчейн.
Существует white paper в которой описано, каким образом могут производиться p2p транзакции (или общение на самом деле) в децентрализованной сети.
Идея эфира - взять биткоин за основу и добавить decentralized agreeements.
Смарт контракты - множество инструкций, выполняемых в децентрализованном виде без регуляции третьими лицами
Технически биткоин тоже имеет смарт контракты, однако в них отсутствует полнота по Тьюрингу
гибридные смарт контракты on chain + off chain agreeements
dapp = decentralized application = decentralized protocol = smart contract
Различие вебов:
- web1:
- the permissionless open sources web with statitic content
- web2
- the permissioned web with dynamic content where companies run your agreements on their servers
- web3
- the permissioned web with dynamic content where decentralized censorship resistant networks run your agreement and code. it generally is accompanied by the idea of user owned ecosystems where the protocols you interact with you also own a portion of, instead of solely being the product
unbreakable agreements and promises нерушимые соглашения и обещания
Если контракт развёрнут
- не может быть изменен
- автоматически выполняется
- любой может увидеть правила соглашения
Uniswap. Помогает свапать erc20 токены. Они в каком то смысле эквивалентны акциям.
- Децентрализация
- прозрачность и гибкость(transparency & flexibility)
- скорость и эффективность
- защищенные и неизменяемые
- устранение рисков контрагентов
DeFi - децентрализованные финансы DAOs - организации, управляемые смарт-контрактами on chain NFTs - не взаимозаменяемый токен
https://faucets.chain.link/ - получить токены почти на любую сеть
https://github.com/smartcontractkit/full-blockchain-solidity-course-js - гит курса
https://sepolia.etherscan.io/ - проверка транзакций (sepolia)
Майнеры или валидаторы получают крипто за процесс проведения транзакций.
Gas - unit of computational measurement
the more complex your transaction is the more gas you have to pay
Mining - the process of finding the 'solution' to the blockchain 'problem' (finding special hash to bruteforce nonce)
Block: - list of transactions mined together
private key for signing transactions
Node - single instance in a decentralized network
Consensus is the mechanism used to agree on the state of a blockchain
Proof of work - mining and guys are miners
Proof of stake and guys are validators
POS - randomly choose to propose the new block and then the rest of the validators will validate if that node has proposed the block
the mean is: blockchain of blockchains
Any time you change something on-chain, including making a new contract, it happens in a transaction
view and pure functions disallow modification of state
Мы всегда платим газ, когда модифицируем state блокчейна
EVM can access and store information in six places:
- Stack
- Memory
- Storage
- CallData
- Code
- Logs
function addPerson(string memory _name, uint256 _favoriteNumber) public{
people.push(People(_favoriteNumber, _name));
}
memory нужна для масивов, мапингов итд для того, чтобы добавить их в функцию, как параметр
example:
mapping (string => uint256) public nameToFavNum;
EVM - is a standandard of how to deploy smart-contracts to eth blockchain
the easiest way to deploy - choose testnet in web remix ide, connect metamask and deploy.
Contracts interacting with each other is imp part of dev.
Важно соблюдать версионность контрактов
ABI - application binary interface
Example:
[
{
"inputs": [],
"name": "createSimpleStorageContact",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_simpleStorageIndex",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_simpleStorageNumber",
"type": "uint256"
}
],
"name": "sfStore",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "simpleStorageArray",
"outputs": [
{
"internalType": "contract SimpleStorage",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]
explainer
Ether is sent to contract
is msg data empty?
/
yes no
/
receive()? fallback()
/
yes no
/
receive() fallback()