Call
bytes memory args = abi.encodeWithSignature("set(uint256)", newPrice);
(bool success, bytes memory retData) = feed.call.value(msg.value)(args);
StaticCall
Same as call, but will revert on state changes
bytes memory args = abi.encodeWithSignature("set(uint256)", newPrice);
(bool success, bytes memory retData) = feed.staticcall(args);
DelegateCall
- same as call, but will run in the context of the calling contract
- how library is implemented
bytes memory args = abi.encodeWithSignature("set(uint256)", newPrice);
(bool success, bytes memory retData) = feed.delegatecall(args);
### Context
- The environment/data available to the function during execution
* account (storage)
* stack
* memory
* message call data
### Account
* 2 types of accounts:
- externally owned account (EOA)
- contract account
* Account contains: balance, a nonce, bytecode, and stored data (storage)
* EOA has empty bytecode and storage
Account Storage
- This is where state variables are stored
- It is persistent between function calls and transactions
- It is a key-value mapping of 2256 keys; each value is 32 bytes long
### Stack
* All computations are performed on the stack
* It has a maximum of 1024 elements
* Access to stack is limited to the top elements
* Access to elements by pop/push to stack
### Memory
* Memory is volatile
* It is mainly used to store data during execution
* Each message call starts with a cleared memory
Message Call Data
- msg.data: the input data for the function call
- msg.sender: the sender of the message
- msg.value: number of wei sent with the message
This
- this refers to the current contract for non-delegated calls
- this refers to the caller contract for delegated call
Caller
- tx.origin is the sender of the transaction (full call chain)
- msg.sender is the sender of the current message call
### Non-Delegated Message Call

### Delegated Message Call

### Sender Context

State Variables Storage Layout
- Solidity generates code that saves variable values in their declaration order.
- Variable first was declared first, it’s stored in slot 0
- Items that need less than 32 bytes are packed together. See Rules
contract Sample {
uint first; // storage slot 0
uint second; // storage slot 1
}