Skip to content

Instantly share code, notes, and snippets.

@yojoots
Created May 1, 2025 18:13
Show Gist options
  • Save yojoots/bd2bedc4981874cd72d5fc0a543d1b54 to your computer and use it in GitHub Desktop.
Save yojoots/bd2bedc4981874cd72d5fc0a543d1b54 to your computer and use it in GitHub Desktop.
#!/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