Created
January 2, 2024 12:09
-
-
Save shekohex/1e1ac31cf031063b495b186a19eea7af to your computer and use it in GitHub Desktop.
Convert Substrate Address to EVM
This file contains 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
import { decodeAddress } from "https://esm.sh/@polkadot/util-crypto"; | |
import { u8aToHex } from "https://esm.sh/@polkadot/util"; | |
const input = Deno.args[0]; | |
if (!input) { | |
console.error("usage: deno run substrateToEvm.ts <SUBSTRATE_ADDRESS_HERE>"); | |
Deno.exit(1); | |
} | |
const accountId = decodeAddress(input); | |
const res = accountId.subarray(0, 20); | |
const output = u8aToHex(res); | |
console.log({ input, output }); | |
// run using: | |
// $ deno run substrateToEvm.ts <SUBSTRATE_ADDRESS_HERE> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment