Skip to main content

E0045: Explicit Disclosure Required for Public Binding

This error is raised when a public target receives a value that is not already public.

Public targets include:

  • storage bindings
  • let pub local bindings

Example: public write from private RHS (error)

utxo Counter {
storage {
let mut counter: i64;
}

main fn update(nextCounter: i64) {
counter = nextCounter; // Error: nextCounter is private
}
}

Fix (UTxO entrypoints): make the parameter public

If the incoming value is intended to be public, mark the parameter as pub and assign directly:

utxo Counter {
storage {
let mut counter: i64;
}

main fn update(pub nextCounter: i64) {
counter = nextCounter; // OK
}
}

Alternative fix: explicitly disclose a private value

If the source value must remain private until assignment, convert it at the write boundary:

main fn update(nextCounter: i64) {
counter = disclose(nextCounter); // OK
}

The same rule applies to let pub initializers:

let pub w = x + y;              // Error if x + y is private
let pub w = disclose(x + y); // OK