To resolve an address, we can check for whether or not the address is already included in our storage mapping. Here's some sample code using the Ethers JS methods we've used earlier, and our global contractAddress state.
Let's see an example
const searchForyourDomain = async () => {
const fetchAddress = await contractAddress.domains(nameState.toString()); //nameState is the accepted input from the user
if (fetchAddress.slice(0, 5) === "0x000") { //if the selected name belongs to the dead address, ie has not been minted yet
//do stuff
} else {
//do other stuff
}
};
You can of course make the code yours by setting a loading animation while this function runs to update your frontend. In the below example, we set the actual Ethereum hexadecimal address gotten from the searchForyourDomain function to some state, and then use that address to execute the sending function.
const searchForyourDomain = async () => {
const fetchAddress = await contractAddress.domains(nameState.toString()); //nameState is the accepted input from the user
if (fetchAddy.slice(0, 5) === "0x000") { //if the selected name belongs to the dead address, ie has not been minted yet
alert('This name is not minted yet! Do not send any assets!')
} else {
setActualAddress(fetchAddress)
}
Now we can use that address we fetched to do things, like make transactions behind the scenes.
For a simple transaction, you can use the following code: