Ethereum: creation of unique addresses based on human readability
The Blockchain Ethereum has introduced various concepts to improve the user’s experience and the validation of transactions. One of these ideas is to generate unique addresses based on certain characters, similar to how the functions of Hash Sha256 validate transactions. In this article, we will explore the concept of creation of unique Ethereum addresses starting from specific characters, such as “Joeanonymousserb7pmqyva8jrpzdcqlq”.
The problem:
In the current system, most Ethereum portfolios require a 42 -character alphanumeric string to generate an address. This string is generated using the Sha-256 hash function, which makes it difficult for humans to read and understand. For example, we consider the following example:
`0x ...
This hexadecimal representation of the number0x00000000000000000000000000000000000000000000000000000000000000000000000000is practically illegible.
The solution:
To create unique Ethereum addresses based on human readability, we can use a personalized hash function that incorporates specific characters into the address. A possible approach is to use the "B58Address" coding scheme, which converts the hexadecimal numbers into man -legible strings using a combination of letters and figures.
Let's examine how it works with our original example:
0x ...
To create a legible address starting from "Joeanonymousserb", we can combine these characters with other alphanumeric characters. A possible implementation is to use the "B58Address" coding scheme, which generates an address like this:
Bash
Joeanonymousserb7pmqyva8Jrpzdcqlq
`
This codified string is more readable and easier to understand than the original hexadecimal representation.
Implementation of personalized hash functions:
To create unique Ethereum addresses based on specific characters, we can implement personalized hash functions that incorporate these characters into the address. For example:
- Coding based on ASCII: Use the ASCII values of the characters to generate an alphanumeric string of 42 characters.
2
4
Example code:
Here is an example of an example of a personalized hash function in solidity, which generates addresses starting from "Joeanonymousserb":
Solidity
Pragma solidity ^0.8.0;
import “
import “
Customaddressgen contract {
GenerateDress function (string memory _firstchars) public return (address) {
// convert the ASCII values of hexadecimal characters
Uint8 [] Ascivalues memory = New Uint8 [] (_ Firstchars.length);
For (Uint256 i = 0; i <_firstchars.length; I ++) {
ascivalues [i] = uint8 (bytes (_firstchars [i]));
}
// generates a 42 -character random alphanumeric string using ASCII values
String Memory Hexstring = “”;
For (Uint256 i = 0; i <42; I ++) {
Uint8 Charcode = ASIIVALUES [i] % 10;
Charcode += 32; // Pass in capital letters for human readability
If ((i & 1) == 0) {// add only a letter of letter
Hexstring += string (charcode);
} Else {// we hang a character of figures
Hexstring += String (Uint8 (ascivalues [i]));
}
}
// Convert hexadecimal string to direct using the B58 coding scheme
Bytes Memory Encodedhex = abi.encodewithsigner (address ()). Param (0, Byte (Hexstring));
Return EIP55DDresses ().