Created
May 1, 2025 18:13
-
-
Save yojoots/bd2bedc4981874cd72d5fc0a543d1b54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const { realioNetworkToEth, ethToRealionetwork } = require('@realiotech/address-generator'); | |
// Get the address from command line arguments | |
const address = process.argv[2]; | |
if (!address) { | |
console.error('Error: Please provide an address as a command line argument'); | |
console.error('Usage: node address-converter.js <address>'); | |
process.exit(1); | |
} | |
try { | |
// Check if the address is a Realio address (starts with 'realio') | |
if (address.startsWith('realio')) { | |
const ethAddress = realioNetworkToEth(address); | |
console.log(`Realio address: ${address}`); | |
console.log(`EVM address: ${ethAddress}`); | |
} | |
// Check if the address is an EVM address (starts with '0x') | |
else if (address.startsWith('0x')) { | |
const realioAddress = ethToRealionetwork(address); | |
console.log(`EVM address: ${address}`); | |
console.log(`Realio address: ${realioAddress}`); | |
} | |
// If the address doesn't match either format | |
else { | |
console.error('Error: Invalid address format'); | |
console.error('The address must start with either "realio" or "0x"'); | |
process.exit(1); | |
} | |
} catch (error) { | |
console.error('Error converting address:', error.message); | |
process.exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment