# Understanding Ether Transfers and ABI in Solidity
When you start writing smart contracts in Solidity, two things are very common
1. How ETH is sent between contracts
2. How data is passed between contracts using ABI
Let’s go through them in a simple way
---
## Part 1: Sending ETH in Solidity
There are three main ways to send ETH
### 1. transfer
```solidity
payable(address).transfer(amount);
```
* Sends ETH but only with 2300 gas
* If it fails, the whole transaction reverts
It was once considered safe but now it can fail because gas costs have changed
---
### 2. send
```solidity
bool success = payable(address).send(amount);
if (!success) {
// handle failure
}
```
* Works like transfer (still 2300 gas)
* Returns true or false instead of reverting
Gives more control but still limited by the gas restriction
---
### 3. call (preferred)
```solidity
(bool success, ) = payable(address).call{value: amount}("");
require(success, "Transfer failed");
```
* Forwards all gas or a custom amount
* Returns success and data
* This is the recommended way to send ETH today
**Conclusion**
* transfer is outdated
* send is also outdated
* call is flexible and future proof
---
## Part 2: ABI (Application Binary Interface)
The ABI is like a translator. It changes human readable function calls into bytes that the EVM understands. When you call a function like
```solidity
myContract.updateData(5);
```
The call is converted into bytes before being sent to the blockchain. When the function returns something, it is converted back from bytes into readable values
---
### Encoding
Encoding means turning data into bytes
* `abi.encode` → standard encoding
* `abi.encodePacked` → compact encoding
* `abi.encodeWithSignature` → adds function selector
---
### Decoding
Decoding means turning bytes back into the original values
```solidity
(uint256, address) = abi.decode(data, (uint256, address));
```
---
### Function Selectors
Every function call starts with the first 4 bytes of the hash of the function signature. This is called the selector. After the selector, the arguments are encoded and sent along
Example: calling `updateData(5)` produces
```
0x6057361d0000000000000000000000000000000000000000000000000000000000000005
```
* First 4 bytes = selector
* Rest = encoded argument
---
### Low Level Call with ABI
One contract can call another contract’s function using call with ABI encoding. You encode the function and arguments, then send it using call. The other contract decodes and runs the function
---
## Why It Matters
* ETH transfers using call move money between contracts
* ABI encoding and decoding moves data between contracts
Together they make DeFi apps, DAOs, NFTs and many other blockchain applications possible
---
## Final Notes
* Use call for ETH transfers with proper checks
* ABI is what lets contracts talk to each other
* Encoding = readable data to bytes
* Decoding = bytes back to readable data
---