Skip to main content
Helpful?

VanityAddressLib

Git Source - Generated with forge doc

A library to score addresses based on their vanity

Functions

betterThan

Compares two addresses and returns true if the first address has a better vanity score

function betterThan(address first, address second) internal pure returns (bool better);

Parameters

NameTypeDescription
firstaddressThe first address to compare
secondaddressThe second address to compare

Returns

NameTypeDescription
betterboolTrue if the first address has a better vanity score

score

Scores an address based on its vanity

Scoring rules: Requirement: The first nonzero nibble must be 4 10 points for every leading 0 nibble 40 points if the first 4 is followed by 3 more 4s 20 points if the first nibble after the 4 4s is NOT a 4 20 points if the last 4 nibbles are 4s 1 point for every 4

function score(address addr) internal pure returns (uint256 calculatedScore);

Parameters

NameTypeDescription
addraddressThe address to score

Returns

NameTypeDescription
calculatedScoreuint256The vanity score of the address

getLeadingNibbleCount

Returns the number of leading nibbles in an address that match a given value

function getLeadingNibbleCount(bytes20 addrBytes, uint256 startIndex, uint8 comparison)
internal
pure
returns (uint256 count);

Parameters

NameTypeDescription
addrBytesbytes20The address to count the leading zero nibbles in
startIndexuint256
comparisonuint8

getNibble

Returns the nibble at a given index in an address

function getNibble(bytes20 input, uint256 nibbleIndex) internal pure returns (uint8 currentNibble);

Parameters

NameTypeDescription
inputbytes20The address to get the nibble from
nibbleIndexuint256The index of the nibble to get
Helpful?