Using the popCapsule Oracle
popCapsule
is used for passing artbitrary data. We have not yet included this in Aztec.nr, so it is a bit more complex than the other oracles. You can follow this how-to:
1. Define the pop_capsule function
In a new file on the same level as your main.nr
, implement an unconstrained function that calls the pop_capsule oracle:
pop_capsule
#[oracle(popCapsule)]
unconstrained fn pop_capsule_oracle<let N: u32>() -> [Field; N] {}
// A capsule is a "blob" of data that is passed to the contract through an oracle.
pub unconstrained fn pop_capsule<let N: u32>() -> [Field; N] {
pop_capsule_oracle()
}
Source code: noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/capsule.nr#L3-L11
2. Import this into your smart contract
If it lies in the same directory as your smart contract, you can import it like this:
import_pop_capsule
use crate::capsule::pop_capsule;
Source code: noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr#L35-L38
3. Use it as any other oracle
Now it becomes a regular oracle you can call like this:
pop_capsule
let packed_public_bytecode: [Field; MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS] =
pop_capsule();
Source code: noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr#L49-L52