---
# System prepended metadata

title: ' Smart Contract Essentials: delegatecall, call, ERC1155 and Gas Saving'

---


#  Smart Contract Essentials: delegatecall, call, ERC1155 and Gas Saving

Smart contracts are powerful because they can interact with each other, handle many types of tokens, and be optimized to save gas. Let’s break down the key ideas in simple terms.

---

### 🔹 Call and delegatecall

`call` is used to interact with another contract and runs in the target contract’s context.
`delegatecall` also runs code from another contract but it keeps the caller’s storage and context. This is why `delegatecall` is often used in proxy and upgradeable contracts, while `call` is used for normal interactions.

---

### 🔹 Function Selectors

Every function in Solidity has a unique ID called a selector. It is the first 4 bytes of the keccak256 hash of the function signature. The selector tells the EVM which function to execute when data is sent to a contract.

---

### 🔹 Calling Other Contracts

Contracts can talk to each other either safely through defined interfaces or flexibly with low-level calls. This makes it possible to build systems where one contract depends on another, like DeFi apps or marketplaces.

---

### 🔹 ERC1155

ERC1155 is a multi-token standard that supports both fungible and non-fungible tokens in one contract. It allows batch transfers and efficient token management, making it popular in gaming, collectibles, and marketplaces.

---

### 🔹 Gas Saving Techniques

Gas efficiency is key in Solidity. Some simple tricks include:

* Use **calldata** instead of memory for function inputs that are only read.
* Load state variables into memory before loops to avoid repeated storage reads.
* Use **++i** instead of i++ inside loops.
* Cache array elements locally instead of reading from storage many times.
* Apply short-circuit logic (`&&` and `||`) so conditions stop early when possible.

---

###  Wrap Up

Understanding low-level calls, function selectors, multi-token standards like ERC1155, and gas optimization practices gives developers the tools to build contracts that are powerful, flexible, and cost-effective on Ethereum.

---

