diff --git a/packages/status-js/src/utils/payload-to-id.ts b/packages/status-js/src/utils/payload-to-id.ts new file mode 100644 index 00000000..9db98a21 --- /dev/null +++ b/packages/status-js/src/utils/payload-to-id.ts @@ -0,0 +1,12 @@ +import { keccak256 } from 'ethereum-cryptography/keccak' +import { bytesToHex } from 'ethereum-cryptography/utils' + +export function payloadToId( + publicKey: Uint8Array, + payload: Uint8Array +): string { + const hash = keccak256(new Uint8Array([...publicKey, ...payload])) + const hex = bytesToHex(hash) + + return `0x${hex}` +}