Matrix AI Network integration tutorials — Part 1.1: Converting an MAN address to ETH address (JS, NodeJS), Beginner level

Matrix AI Network
2 min readAug 13, 2021

Author: Delbypoc

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).

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 convert an MAN address (Mainnet) to an ETH address.

You can find the article which shows how to convert an ETH to a MAN address here (and the prerequisites I use):

Let’s start programming!

I will start by creating a function that checks if the address we provided is VALID (has valid characters, we will use regex for that, make sure that the provided address starts with MAN, matches ‘.’, then it is followed by a string of 21–29 characters: a…Z, A…Z, 0…9 (matches 21–29 times, after MAN.)):

Also, we will check for cyclic redundancy:

Then we will decode the address (base 58 encoded string, without the last Character) then convert it to hex and add 0x before it:

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

For ‘MAN.2LSfiVSmKx8PD9YUbdVGuHEhDY3Jz’ it should return ‘0x5fd71cf221e450e619638338bd21871229835261’

For ‘MAN.2LSfiVSmKx8PD9YUbdVGuHEhDY3JzO’ it should return ‘MAN.2LSfiVSmKx8PD9YUbdVGuHEhDY3JzO is not a valid MAN address’

For more documentation on the packages used, you can check: https://www.npmjs.com/package/bs58

https://www.npmjs.com/package/polycrc

Also, check out the official Matrix AI Network Developer Portal: dev.matrix.io

--

--

Matrix AI Network

The Matrix AI Network was founded in 2017. In 2023, we enter Matrix 3.0 blending neuroscience with our previous work to realize the vision of the Matrix films.