marethyu
marethyu

Reputation: 215

Get value from a promise near_sdk

I'm having a function that return a promise expected to return a u128 value from another contract. How can I get this value from this promise? Here is my codes: enter image description here enter image description here

I tried async await in future/rust but it didn't work

Upvotes: 1

Views: 131

Answers (1)

Benjamin Kurrek
Benjamin Kurrek

Reputation: 1094

The value is baked into the call_result variable you have there. The promise will be scheduled after query_staked_amount finishes and then once the promise finishes executing, the callback query_staked_amount_callback is invoked.

In this callback, the result of the original promise (get_staked_amount) will be available in that variable you have call_result.

Hope that answers your question.

Upvotes: 1

Related Questions