Use this library to integrate your app with the a nois proxy.
```rust
pub fn instantiate(
deps: DepsMut,
env: Env,
_info: MessageInfo,
msg: InstantiateMsg,
) -> Result
```rust use nois::ProxyExecuteMsg;
pub fn executeestimatepi(
deps: DepsMut,
env: Env,
_info: MessageInfo,
jobid: String,
) -> Result
let res = Response::new().add_message(WasmMsg::Execute {
contract_addr: nois_proxy.into(),
msg: to_binary(&ProxyExecuteMsg::GetNextRandomness { job_id })?,
funds: vec![],
});
Ok(res)
} ```
Create a ExecuteMsg
enum case called Receive
```rust use cosmwasmschema::{cwserde, QueryResponses};
use nois::NoisCallback;
pub enum ExecuteMsg { // ...
Receive {
callback: NoisCallback,
},
} ```
and use it:
```rust
pub fn execute(
deps: DepsMut,
env: Env,
info: MessageInfo,
msg: ExecuteMsg,
) -> Result
ExecuteMsg::Receive { callback } => execute_receive(deps, env, info, callback),
}
}
// ...
pub fn executereceive(
deps: DepsMut,
_env: Env,
_info: MessageInfo,
callback: NoisCallback,
) -> Result
let NoisCallback { job_id, randomness } = callback;
let randomness: [u8; 32] = randomness
.to_array()
.map_err(|_| ContractError::InvalidRandomness)?;
// use randomness 🎉
} ```