# Etherium ## Basic terms Basic terms for beginner, explain how blockchain works, etc. https://ethereum.org/en/developers/docs/intro-to-ethereum/ ### Account https://ethereum.org/en/developers/docs/accounts/ `An Ethereum account is an entity with an ether (ETH) balance that can send transactions on Ethereum. Accounts can be user-controlled or deployed as smart contracts.` ### Transaction: https://ethereum.org/en/developers/docs/evm/#transactions `Transactions are cryptographically signed instructions from accounts.` - So just a signed EVM program?? Everything is opcode?? - The fee to submit a transaction is called "gas" - 2 types of transaction: - Transactions that result in message calls --> basically code that call a smart contract, aka just like an API call - Transactions that result in contract creation. - Gas costs for contract deployment are far higher: https://ethereum.org/en/developers/docs/smart-contracts/#permissionless - External Function Calls: https://docs.soliditylang.org/en/latest/control-structures.html#external-function-calls - **External Function Calls (aka a special message call) vs transaction**: https://ethereum.stackexchange.com/questions/765/what-is-the-difference-between-a-transaction-and-a-call - Reentrancy only happens with transaction, not External Function Calls #### call() method vs delegatecall() method: - Despite the name, these are both used to perform **transaction** - call: current smart contract call another contract --> msg.sender is current smart contract, storage belongs to the new smart contract - delegatecall: current smart contract pull the code of another contract to current context to execute --> msg.sender stays the same, storage is of current contract - https://solidity-by-example.org/delegatecall/ ### Node https://ethereum.org/en/developers/docs/nodes-and-clients/ `Ethereum is a distributed network of computers (known as nodes) running software that can verify blocks and transaction data` - Peer-to-peer network, so the actual machines that runs EVM programs are the nodes - A node has to run two clients: a consensus client and an execution client: - `The execution client listens to new transactions broadcasted in the network, executes them in EVM, and holds the latest state and database of all current Ethereum data.` --> the thing that implement EVM and execute EVM instruction - The consensus client: feel like I dont need to care about this yet. - When message calls transaction happen, the node just take the contract's opcode from the blockchain then execute it Side note: - Only validator (people that put down 32 ETH) can receive part of the gas money - Normal people that is not validator doesn't have any benefit if they become a node --> beside privacy reason, what motivate people to become a node? ## Smart contract and EVM: https://ethereum.org/en/developers/docs/evm/ https://ethereum.org/en/developers/docs/smart-contracts/ https://ethereum.org/en/developers/docs/smart-contracts/anatomy/ - The EVM executes as a stack machine - Basically a smart contract is a freaking bot - It has address (similar to user's wallet address), balance,... just like a user - "When a smart contract is deployed on the Ethereum blockchain, its bytecode is stored on the blockchain as a transaction." ==> From: https://josnif.hashnode.dev/understanding-abi-and-bytecode-in-ethereum-smart-contract-development-concepts-tools-and-best-practices ==> help with integrity of the code. - https://ethereum.stackexchange.com/questions/149140/how-to-find-the-bytecode-of-ethereum-smart-contract-by-just-its-address - The code for the vast majority of smart contracts is open-source --> Helps with transparency --> no rev needed :sadge: ## Smart contract security: https://ethereum.org/en/developers/docs/smart-contracts/security/#mitigate-common-smart-contract-vulnerabilities ## Non-native token https://ethereum.org/en/developers/docs/standards/tokens/erc-20/#top https://www.dappuniversity.com/articles/code-your-own-cryptocurrency-on-ethereum Most non native tokens seems to be just smart contracts with a mapping of (address->amount). ## Blockchain oracle: https://cointelegraph.com/learn/what-is-a-blockchain-oracle-and-how-does-it-work ## Fallback method: https://solidity-by-example.org/sending-ether/