Skip to main content
The @zkp2p/contracts-v2/utils/protocolUtils module provides utility functions for protocol operations including hashing, currency handling, and intent calculations.

Import Utilities

Currency Constants

The Currency object provides pre-computed Keccak256 hashes for all supported currencies:

Supported Currencies

All 33 supported currency codes:
  • USD - United States Dollar
  • EUR - Euro
  • GBP - British Pound Sterling
  • JPY - Japanese Yen
  • CHF - Swiss Franc
  • CAD - Canadian Dollar
  • AUD - Australian Dollar
  • NZD - New Zealand Dollar
  • CNY - Chinese Yuan
  • HKD - Hong Kong Dollar
  • SGD - Singapore Dollar
  • INR - Indian Rupee
  • IDR - Indonesian Rupiah
  • MYR - Malaysian Ringgit
  • PHP - Philippine Peso
  • THB - Thai Baht
  • VND - Vietnamese Dong
  • CZK - Czech Koruna
  • DKK - Danish Krone
  • HUF - Hungarian Forint
  • NOK - Norwegian Krone
  • PLN - Polish Zloty
  • RON - Romanian Leu
  • SEK - Swedish Krona
  • AED - UAE Dirham
  • ARS - Argentine Peso
  • ILS - Israeli Shekel
  • KES - Kenyan Shilling
  • MXN - Mexican Peso
  • SAR - Saudi Riyal
  • TRY - Turkish Lira
  • UGX - Ugandan Shilling
  • ZAR - South African Rand

Hashing Functions

getKeccak256Hash

Compute Keccak256 hash of a string value:
value
string
required
The string value to hash
return
string
Keccak256 hash as a hex string with 0x prefix

calculatePaymentMethodHash

Calculate payment method hash (alias for getKeccak256Hash):

Intent Hash Calculation

calculateIntentHash

Calculate the unique hash for an intent, constrained to the Circom field:
orchestrator
string
required
Address of the Orchestrator contract
intentCounter
BigNumber | number
required
The intent counter value (can be ethers BigNumber or number)
return
string
Intent hash constrained to Circom field, zero-padded to 32 bytes
The intent hash is computed as keccak256(orchestrator, intentCounter) modulo the Circom field prime: 21888242871839275222246405745257275088548364400416034343698204186575808495617

Currency Helpers

getCurrencyCodeFromHash

Reverse lookup to get currency code from its hash:
hash
string
required
The currency hash to look up
return
string
Currency code (e.g., “USD”, “EUR”) or empty string if not found

Complete Example

Building Intent Parameters

Currency Validation

Type Definitions

Next Steps

Payment Methods

Work with payment method configurations

Constants

Access protocol constants