Smart Contracts Flashcards
Whats is Blockchain
distributed database that maintains a growing list of ordered records called blocks.
How are Blocks linked
Uisng cryptography. Each block contains a hash of the previous block, a timestamp, and transaction data.
Smart Contract
Self-Executing contract with terms directly written into code
Smart Contract (Automation?)
Automatically enforces rules and conditions once pre-defined criteria are met
Key Features (Smart Contract)
(AIDT)
Automation
Immutable: Once deployed, can’t be altered
Decentralised
Transparent and Secure
Smart Contract Workflow
(WDLER)
1: Written
2. Deploy
2: Listen
3: Execute
4: Record
Registry
Record of all deployed contracts, allowing access, and updates
Registry (Contains)
bytecode,
ABI,
developer Docs,
critical information
Registry (Available)
Available at runtime to all participants
Address Book
Used to manage ethereum strings of Hex.
Address Book (How it works)
when a new instance of a user or contract is detected it is added to the book with a link to the contract.
all instances of a contract are listed and a REST API for each is auto-generated.
REST API can be used from any node.
Truffle
Truffle is an automated testing framework to test smart contracts.
Ways to write a test
Javascript and Typescript
Solidity
All files in ./test directory
Truffle will only run .js, .ts, .es, .es6, .jsx, and .sol.
Encryption
The use of a key to encode information so that it cannot be read by nodes without the corresponding decryption key.
Components of smart contract
Pragma directive: solidity compiler version.
Contract Definition: Basic buildign block
State variables: variables
Functions: Blocks of code defining the operations and logic
Modifiers: custom conditions used to modify behaviour of functions
Events: logging mechanisms
Fallback and Receive: Special functions to handle Ether transfers
Data Types: Defines the type of variables