## Understanding Transactions on StarkNet: A Comprehensive Overview StarkNet, a Layer 2 scaling solution for Ethereum, offers a powerful transaction overview tool called [StarkScan](https://sepolia.starkscan.co/tx/0x39ba798537ff0b51a1f35be27857265244841b749ea213d2df5c0813514bb62#overview). This guide will walk you through the key elements of a StarkNet transaction, helping you navigate the blockchain landscape with ease. **Transaction Basics** * Transaction Hash: A unique identifier for your transaction, serving as your blockchain receipt. * Status: Indicates the transaction's current state: Not Received → Received → Pending → Accepted on L2 → Accepted on L1 * Not Received: Transaction hasn't been recognized by the network yet * Received: Network has acknowledged the transaction but hasn't processed it * Pending: Transaction is waiting to be included in a block * Accepted on L2: Successfully processed on StarkNet (Layer 2) * Accepted on L1: Confirmed on Ethereum (Layer 1), completing the process **Block Details:** * Block Hash: The ID of the block containing your transaction * Block Number: The block's position in the blockchain sequence * Timestamp: When the transaction was included in a block * Transaction Type: Describes the action being performed (e.g., `INVOKE_FUNCTION` for smart contract interactions) **Financial Details** * Tokens Transferred: Shows the sender, receiver, and amount of tokens moved * Gas and Fees: * Gas Consumed: Computational resources used * Actual Fee: Total fees paid * Max Fee: Upper limit on transaction fees * Nonce: A unique number preventing double-spending and ensuring correct transaction order **Technical Aspects** * Input Data: Parameters passed to the smart contract function In my example , in a `transfer(recipient, amount)`: recipient address and amount of tokens ![Screenshot 2024-09-26 at 2.51.54 AM](https://hackmd.io/_uploads/BkFrCVz0R.png) * Signature: Verifies transaction authenticity using the sender's private key Prevents tampering and ensures only the rightful owner can initiate transactions * **Recipient**: The address that is receiving the tokens. * **Amount**: The value of tokens to be transferred. In my example, it’s `20000000000000000000`, which would represent 20 tokens if we are dealing with a token with 18 decimals (common for tokens like Ethereum or ERC20 tokens). ![Screenshot 2024-09-26 at 2.51.14 AM](https://hackmd.io/_uploads/S1MXRNfR0.png) * Execution Resources: This section outlines the computational resources consumed to execute the transaction. - **STEPS**: The number of computational steps the transaction took to execute (11152 in my case). - **MEMORY HOLES**: Unused memory spots during execution (0 means none). - **EC_OP_BUILTIN**: Elliptic curve operations used for cryptographic calculations (3 in this case). - **PEDERSEN_BUILTIN**: Operations using the Pedersen hash function (25 of these operations). - **RANGE_CHECK_BUILTIN**: Checks to ensure values are within a valid range (194 checks here). - **L1_GAS**: The amount of gas consumed for interactions with Layer 1 (4646 units of gas). - **L1_DATA_GAS**: Gas used for data transmission to Layer 1 (0 means no data was transmitted). ![Screenshot 2024-09-26 at 2.52.54 AM](https://hackmd.io/_uploads/BkMt0VMCC.png) **Transaction Insights** * Events: In blockchain events are a way for smart contracts to log specific actions that happen during the execution of a transaction. These events can be "listened to" by external applications or users to track contract activities without interacting with the blockchain directly. In my case of a **Transfer Event**, this typically happens when tokens are transferred from one address to another. The event will contain important information such as: - **Sender**: The address sending the tokens. - **Receiver**: The address receiving the tokens. - **Amount**: The number of tokens being transferred. These events are important because they create a record of token movements and other actions that can be easily accessed by users, developers, or analytics tools. ![Screenshot 2024-09-26 at 3.46.25 AM](https://hackmd.io/_uploads/S1JzjSMR0.png) * Message Logs: **Message Logs** help monitor and track communication between different smart contracts or blockchain layers, ensuring transparency and traceability in cross-layer operations. * Internal Calls: This refer to function calls that are made within the smart contract itself. These are calls that might not be directly triggered by an external user but are part of the logic flow in a contract. * **`__execute__`**: This is often an internal function that handles the logic for executing various operations in the smart contract. * **`transfer`**: This is the internal function that actually moves tokens from one account to another within the smart contract. ![Screenshot 2024-09-26 at 3.45.42 AM](https://hackmd.io/_uploads/B181irfRC.png) Feel free to connect with me or share your feedback on any of these platforms: [![Twitter](https://img.shields.io/badge/X-1DA1F2?logo=twitter&logoColor=white&style=for-the-badge)](https://x.com/1techhunter) [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?logo=linkedin&logoColor=white&style=for-the-badge)](https://www.linkedin.com/in/nwankwo-stephanie-4ba1311a7/) [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white&style=for-the-badge)](https://github.com/GoSTEAN) [![Email](https://img.shields.io/badge/Email-D14836?logo=gmail&logoColor=white&style=for-the-badge)](mailto:stephanienwankwo0@gmail.com) Always open to collaborate and explore new tech! 💡