# Generating a Vanity Address(JS, NodeJS), Beginner level

**by Delbypoc**

\ <br>

This tutorial is for educational purposes only, I’m not responsible for any losses, damages, or other liabilities which may occur by using any info/code provided here(or anywhere else it is posted).

!\[Text

Description automatically generated]\(<https://www.matrix.io/gitbook/Guides/Guides_11.fld/image001.png>)

I’m under no circumstances a Javascript professional (or a JS Ninja/Expert)!

The code is not production ready! (only for learning purposes)

In this guide, I’m going to show you how to generate an vanity MAN address (Mainnet).

To keep it simple, for this program we will make use of the ETH to MAN address convertor we displayed in the last article:

\[!\[Graphical user interface, text, application, email

Description automatically generated]\(<https://www.matrix.io/gitbook/Guides/Guides_11.fld/image002.png>)]\(<https://medium.com/@delbypoc/matrix-ai-network-integration-tutorials-part-1-converting-an-eth-address-to-man-address-js-db376f17a2d>)

We will make use of the following packages : ‘crypto’, ‘ethereumjs-util’, ‘buffer’, ‘polycrc’, ‘bs58’.

You can install them by using :

npm install ethereumjs-util buffer polycrc bs58

Let’s start programming!

First off, we are going to start by generating a random wallet, we are going to call this function ’generateRandomWallet’:

!\[A picture containing graphical user interface

Description automatically generated]\(<https://www.matrix.io/gitbook/Guides/Guides_11.fld/image003.png>)

Then we will make a function that verifies if the wallet we provide contains the word we choose (the parameter in the function is called ‘input’), we will call this function ‘addressContainsTheInput’:

![](https://www.matrix.io/gitbook/Guides/Guides_11.fld/image004.png)

Then we will make a function that generates a random wallet until it finds one that contains the input (addressContainsTheInput returns true), we will name it ‘generateVanityWallet’:

!\[Graphical user interface

Description automatically generated with low confidence]\(<https://www.matrix.io/gitbook/Guides/Guides_11.fld/image005.png>)

For example, if we want an address that contains the word ‘Enjoy’:

Note: The time it takes to find an address depends on your computer specs (and a bit of luck), it took me around 10 seconds to generate an address that contains the word \`enjoy\`, longer sequences takes more time.

Note: This is not an efficient program, there are better ways to generate a vanity address (especially if you make use of GPU-s core count or CPU multi-threading)

![](https://www.matrix.io/gitbook/Guides/Guides_11.fld/image006.png)

Sample output:

{\
publicAddress: ‘MAN.2ZyEnjoy2tk5yPB2YrziUVTQAFWAV’,\
privateKey:\
‘c17b95305a3d0ad80a4ca4020ab7850cf5e75557b273dbbce625cd5f8c95f286’\
}

Whole program ([**https://github.com/CognitiveProcessing/Matrix-AI-Network-Code-Snippets/blob/main/js/generateVanityAddress.js**](https://github.com/CognitiveProcessing/Matrix-AI-Network-Code-Snippets/blob/main/js/generateVanityAddress.js))

!\[Text

Description automatically generated]\(<https://www.matrix.io/gitbook/Guides/Guides_11.fld/image007.png>)

&#x20;

!\[Text

Description automatically generated]\(<https://www.matrix.io/gitbook/Guides/Guides_11.fld/image008.png>)

For more documentation on the packages used, you can check:

[**https://www.npmjs.com/package/bs58**](https://www.npmjs.com/package/bs58)

[**https://www.npmjs.com/package/buffer**](https://www.npmjs.com/package/buffer)

[**https://www.npmjs.com/package/polycrc**](https://www.npmjs.com/package/polycrc)

[**https://www.npmjs.com/package/ethereumjs-util**](https://www.npmjs.com/package/ethereumjs-util)

[**https://nodejs.org/api/crypto.html**](https://nodejs.org/api/crypto.html)

Also, check out the official Matrix AI Network Developer Portal:

[**dev.matrix.io**](https://www.matrix.io/blog/dev.matrix.io)

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.matrix.io/guides/generating-a-vanity-address-js-nodejs-beginner-level.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
