unshETHZap - Dependencies
Address.sol
This is a solidity library for common address operations. It provides functions to check if an address is a contract, send value to an address, and perform function calls with various conditions. The functions employ low-level operations and handle error conditions, making them safer for use in smart contracts.
Address
A solidity library providing common operations for addresses.
isContract
isContract(address account) internal view returns (bool)
Checks if an address is a contract.
Parameters
- account address: The address to check.
Return Values
- bool: True if the address is a contract, false otherwise.
sendValue
sendValue(address payable recipient, uint256 amount) internal
Sends a specified amount of wei to a recipient address.
Parameters
- recipient address payable: The recipient address.
- amount uint256: The amount of wei to send.
functionCall
functionCall(address target, bytes memory data) internal returns (bytes memory)
Performs a function call on a target address with specified data.
Parameters
- target address: The target address.
- data bytes memory: The function call data.
Return Values
- bytes memory: The raw returned data.
Examples
Using the Address library
This example demonstrates how to use the Address library to perform common address operations.
// Import the Address library
import './Address.sol';
// Use the Address library
function testAddress() public {
address account = msg.sender;
bool isContract = Address.isContract(account);
if (!isContract) {
Address.sendValue(account, 1 ether);
}
bytes memory data = '';
Address.functionCall(account, data);
}