Summary
When loading a Midnight contract, users are currently required to manually input a Private State ID - a field that most users don't understand and shouldn't need to worry about. This creates unnecessary friction in the onboarding flow.
Problem
- Users ask: "What should I put in the Private State ID field?"
- The field is an implementation detail that doesn't provide value to end users
- Manual input increases cognitive load and potential for errors
Proposed Solution
Auto-generate the Private State ID deterministically based on the contract address and wallet address:
// Generate a deterministic ID from contract + wallet
const privateStateId = generateDeterministicId(contractAddress, walletAddress);
// e.g., hash or concatenation like: `${contractAddress}_${walletAddress.slice(-8)}`
Benefits
- Reduced cognitive load - Users don't need to understand this implementation detail
- Fewer errors - No typos, no accidentally reusing IDs
- Smoother onboarding - One less required field
- Automatic state restoration - Same user + same contract = same private state (deterministic)
Implementation Notes
- Remove
privateStateId from getContractDefinitionInputs() in the Midnight adapter
- Generate the ID internally when loading/interacting with contracts
- The ID should be deterministic so private state is automatically restored across sessions
- Consider displaying the generated ID in the contract info panel for transparency
Files to Modify
packages/adapter-midnight/src/adapter.ts - Remove field from getContractDefinitionInputs()
- Transaction/contract loading logic - Add deterministic ID generation
Context
This improvement was identified from user feedback asking what to put in the Private State ID field.
Summary
When loading a Midnight contract, users are currently required to manually input a Private State ID - a field that most users don't understand and shouldn't need to worry about. This creates unnecessary friction in the onboarding flow.
Problem
Proposed Solution
Auto-generate the Private State ID deterministically based on the contract address and wallet address:
Benefits
Implementation Notes
privateStateIdfromgetContractDefinitionInputs()in the Midnight adapterFiles to Modify
packages/adapter-midnight/src/adapter.ts- Remove field fromgetContractDefinitionInputs()Context
This improvement was identified from user feedback asking what to put in the Private State ID field.