How to use the @polkadot/util.u8aToHex function in @polkadot/util

To help you get started, we’ve selected a few @polkadot/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / ui / packages / ui-keyring / src / defaults.ts View on Github external
function toHex (address: string): string {
  return u8aToHex(
    // When saving pre-checksum changes, ensure that we can decode
    decodeAddress(address, true)
  );
}
github vue-polkadot / vue-ui / packages / vue-keyring / src / defaults.ts View on Github external
function toHex(address: string): string {
  return u8aToHex(
    // When saving pre-checksum changes, ensure that we can decode
    decodeAddress(address, true)
  );
}
github polkadot-js / tools / packages / signer-cli / src / cmdSign.ts View on Github external
export default async function cmdSign (account: string, seed: string, type: Curves, [payload]: string[]): Promise {
  await cryptoWaitReady();

  const keyring = new Keyring({ type });
  const pair = keyring.createFromUri(seed);
  const signature = pair.sign(hexToU8a(payload));

  const prefix = new Uint8Array(curvePrefixes[type]);

  console.log(`Signature: ${u8aToHex(u8aConcat(prefix, signature))}`);

  process.exit(0);
}
github polkadot-js / apps / packages / app-accounts / src / vanitygen / cli.ts View on Github external
function showBest (): void {
  const { address, count, mnemonic, offset, seed } = best;

  console.log(`\r::: ${address.slice(0, offset)}${chalk.cyan(address.slice(offset, count + offset))}${address.slice(count + offset)} <= ${u8aToHex(seed)} (count=${count}, offset=${offset})${mnemonic ? '\n                                                        ' + mnemonic : ''}`);
}
github polkadot-js / api / packages / types / src / codec / Enum.spec.ts View on Github external
it('compares against hex', (): void => {
        expect(test.eq(u8aToHex(u8a))).toBe(true);
      });
github polkadot-js / client / packages / client-db / src / state / blockHashAt.spec.js View on Github external
get: (key) => {
          console.log('retrieving', u8aToHex(key));

          return store[u8aToHex(key)] || new Uint8Array([]);
        },
        put: (value, key) => {
github polkadot-js / common / packages / util-crypto / src / address / decode.spec.ts View on Github external
it('decodes the council address', (): void => {
    expect(
      u8aToHex(decode('F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29'))
    ).toEqual(u8aToHex(stringToU8a('modlpy/trsry'.padEnd(32, '\0'))));
  });
github polkadot-js / client / packages / client-wasm / src / index.ts View on Github external
    l.debug((): string => `Importing block #${blockNumber}, ${u8aToHex(blockData.header.hash, 48)}`);
github polkadot-js / api / packages / types / src / AccountIndex.ts View on Github external
toHex (): string {
    return u8aToHex(this.toU8a());
  }
github polkadot-js / ui / packages / react-identicon / src / Identicon.tsx View on Github external
public static getDerivedStateFromProps ({ prefix = IdentityIcon.prefix, value }: Props, prevState: State): State | null {
    try {
      const address = isU8a(value) || isHex(value)
        ? encodeAddress(value, prefix)
        : (value || '');
      const publicKey = u8aToHex(decodeAddress(address, false, prefix));

      return address === prevState.address
        ? null
        : {
          address,
          publicKey
        };
    } catch (error) {
      return {
        address: '',
        publicKey: '0x'
      };
    }
  }