Network ⛓️
Connecting to the Network and sending ETH
The Network feature allows you to connect and get information from the current Ethereum network. You can read information from the currently connected network, allow a user to enable the connection to the current network, and give the User the ability to send ETH.
Want to get started quick with no-code? Check out our no-code template in Webflow!
dapphero-network - Webflow
Webflow
Click "clone" to make it yours!
Prefer to dig in and get your hands dirty with HTML? Remix our Demo on Glitch!
Glitch: The friendly community where everyone builds the web
glitch
Click "remix" to start your own project!

Network Enable

It is required that you implement a Network Enable element in your webpage. This should ideally be a buttontype element that a user clicks to connect to ethereum. Without it, DappHero won't load!
Tag
Property
Required?
Output
data-dh-feature
"network"
Yes
none
data-dh-property-enable
"true"
Yes
none
We recommend that you feature this button prominently, where users will see it immediately. As a matter of privacy and security, DappHero will only be able to process transactions and access your users information once the connection has been approved.
An example of what an Enable button might look like. When a user clicks on it, they will be requested by MetaMask to give their permission to be connected to your website.
1
<button
2
data-dh-feature="network"
3
data-dh-property-enable="true">
4
*Button Text*
5
</button>
Copied!

Network Data

Tag
Property
Required?
Output
To Display Data
data-dh-feature
"network"
Yes
none
data-dh-property-id
"true"
optional
Network Id
data-dh-property-name
"true"
optional
Network Name
data-dh-property-provider
"true"
optional
Network Provider
There are many different kinds of Ethereum networks, each have their own ID. To get the value of the current network ID, use:
1
<div
2
data-dh-feature="network"
3
data-dh-property-id="true">
4
*placeholder text*
5
</div>
Copied!
When your webpage loads, the word "placeholder text" will be replaced with the value of the currently connected Network ID.

Network Name

Along with a Network ID, most public Ethereum networks also have a network name, which can be more intuitive to users than Network ID. Note, if you are connected to a private network or special purpose network, your network may not have a known network name.
1
<div
2
data-dh-feature="network"
3
data-dh-property-name="true">
4
*placeholder text*
5
</div>
Copied!

Network Provider

Currently, users will be bringing their own connection to the Ethereum Blockchain in the form of an in browser wallet such as MetaMask. To get the name of the current provider, use:
1
<div
2
data-dh-feature="network"
3
data-dh-property-provider="true">
4
*placeholder text*
5
</div>
Copied!
Currently DappHero supports only MetaMask for users, but will be expanding the number of providers it supports in the near future.

Transferring ETH

The DappHero Network feature also allows you to let a user transfer ETH. To do this you would add input elements to your webpage that you tag for amount and recipient address respectively.
Current there can be only one instance of ETH transfer per page. This will be changed in a future release of DappHero to allow for multiple transfers per page.
Tag
Property
Required?
Output
FOR SENDING ETH
data-dh-feature
"network"
Yes
none
data-dh-property-transfer
"input"
Yes
none
Input Elements
data-dh-property-input-name
"amount"
Yes
none
data-dh-property-input-name
"address"
Yes
none
Invoke Button
data-dh-property-transfer
"invoke"
Yes
none
Units Modifier
data-dh-modifier-display-units
"ether" | "wei"
optional
Input Modifier
1
<!-- An input field for the amount of ETH to send, with the units set to ETH -->
2
<input
3
data-dh-feature="network"
4
data-dh-property-transfer="input"
5
data-dh-property-input-name="amount"
6
data-dh-modifier-display-units="ether">
7
</input>
8
9
<!-- An input field for the address to receive the ETH -->
10
<input
11
data-dh-feature="network"
12
data-dh-property-transfer="input"
13
data-dh-property-input-name="address">
14
</input>
15
16
<!-- A button to invoke the action of sending ETH and request user signature -->
17
<button
18
data-dh-feature="network"
19
data-dh-property-transfer="invoke">
20
Click to transfer!
21
</button>
Copied!
To require users to send a specific amount of ETH or to a predefined address, you would set the value of the inputs manually and set their style to display: none to effectively hide them from the user.
1
<!-- An input field for the amount of ETH to send, with the units set to ETH -->
2
<input
3
data-dh-feature="network"
4
data-dh-property-transfer="input"
5
data-dh-property-input-name="amount"
6
data-dh-modifier-display-units="ether"
7
style="display:none;"
8
value="<<predefined amount of ETH>>">
9
</input>
10
11
<!-- An input field for the address to receive the ETH -->
12
<input
13
data-dh-feature="network"
14
data-dh-property-transfer="input"
15
data-dh-property-input-name="address"
16
style="display:none;"
17
value="<<predefined address>>">
18
</input>
19
20
<!-- A button to invoke the action of sending ETH and request user signature -->
21
<button
22
data-dh-feature="network"
23
data-dh-property-transfer="invoke">
24
Click to transfer!
25
</button>
Copied!
Last modified 1yr ago