Display different views

  • Displaying different views is very simple. You just need to leverage the UI State.
  • For example, I have a form where my users can enter values into an input and submit a transaction. Then, I want to display a success message once a transaction is successful.
  • I have two different views. Let's call them form and success.
  • Because there are two different views, there will be two different prompt blocks.
prompt :-
get(view, form),
show [
text('ETH -> WETH'),
input(eth, eth),
button('WRAP', [
get(input/eth, ETH),
call_fn(weth, deposit, [ value(eth(ETH)) ], []),
set(view, success).
])
].
  • The prompt above is displayed only if the view is set to form.
  • The view switches to success once the user clicks on the "WRAP" button and the deposit transaction is minted successfully.
prompt :-
get(view, success),
show[
text('ETH successfully swapped!'),
button('New Swap', [ set(view, form) ])
].
  • The prompt above is displayed only if the view is set to success.
  • When the user clicks on the "New Swap" button he will set back the view to form.
The complete dApp treated in this example can be found here - RINKEBY