Skip to content

Commit

Permalink
Create AddressUtils.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jun 16, 2024
1 parent 5e8b7fa commit 4e3dd27
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pragma solidity ^0.8.0;

library AddressUtils {
function isValidAddress(address _addr) internal pure returns (bool) {
return _addr!= address(0);
}

function isContract(address _addr) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(_addr)
}
return size > 0;
}

function encodeAddress(address _addr) internal pure returns (bytes memory) {
return abi.encodePacked(_addr);
}
}

0 comments on commit 4e3dd27

Please sign in to comment.