Skip to content

Instantly share code, notes, and snippets.

@shekohex
Created January 2, 2024 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shekohex/1e1ac31cf031063b495b186a19eea7af to your computer and use it in GitHub Desktop.
Save shekohex/1e1ac31cf031063b495b186a19eea7af to your computer and use it in GitHub Desktop.
Convert Substrate Address to EVM
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