Advanced: Getting the Current User's Address Dynamically
Getting the value of the current user as an input

$CURRENT_USER

A common use case for many smart contracts is to return information from a public view method that is associated with the current user. An example would be retrieving the balance of the current users ERC20 token amount. While you could create a normal input field and let a user populate it with their address, for many use cases this would be an inconvenient solution where you might want to show some smart contract state related to the current user on page load.
To address this common use case, we have created the reserved keyword $CURRENT_USER that can be used inside of inputs for smart contracts.
1
<input
2
data-dh-property-method-id="000"
3
data-dh-property-input-name="<<input method argument name>>"
4
value="$CURRENT_USER"
5
/>
Copied!
In this example, the input field's value would be automatically populated with the value of the current users Ethereum address.
The $CURRENT_USER keyword is particularly useful when the input is hidden. To do this, set the display value of the input to none.
1
<input
2
data-dh-property-method-id="000"
3
data-dh-property-input-name="<<input method argument name>>"
4
style="display:none;"
5
value="$CURRENT_USER"
6
/>
Copied!
Last modified 1yr ago
Copy link