Parsing Response from StdResult<Response>


I am in the learning stage.

How do I parse the response sent from Anchor’s bLunaHub contract’s unbond request? I see this in the contract.

        attr("action", "burn"),
        attr("from", sender),
        attr("burnt_amount", amount),
        attr("unbonded_amount", amount_with_fee),

This is the code in my smart contract trying to execute the unbond at Anchor’s bLunaHub contract.

let unbond_Response = CosmosMsg::Wasm(WasmMsg::Execute {
    contract_addr: bLunaTokenContract,
    msg: to_binary(&cw20::Cw20ExecuteMsg::Send {
        contract: bLunaHubContract,
        amount: Uint128::new(1000000),
        msg: to_binary(&basset::hub::Cw20HookMsg::Unbond {})?,
    funds: vec![],

How do I parse the response stored in unbond_Response? I am trying to get unbonded_amount from the response. But, trying to get it like this - unbond_Response.unbonded_amount gives error. I know this is very simple, but, I cant figure out how to get the value. I see that response is stored in vec![]. How to access these value?


so I haven’t played with this contract in particular.
but typically you use the ‘msg’ to send a message back to you with parameters you require…
so instead of basset::hub::Cw20HookMsg::Unbond, you’d make it send something to your contract with the things you want to see back (eg the amount you sent, or sender or something)

there is also a sub_message

which will repond back to you on success/fail etc

@octalmage might be able to help futher

@petes-fan-club Thank you for the reply.

@octalmage Can you please look into this and let me know your thoughts?