You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Makes a call to a specific contract and returns the value. The hook will cause the component to refresh whenever a new block is mined and the value is changed.
73
+
74
+
Calls will be combined into a single multicall across all uses of *useChainCall* and *useChainCalls*.
75
+
76
+
It is recommended to use `useContractCall`_ where applicable instead of this method.
77
+
78
+
*Parameters*
79
+
80
+
- ``call: ChainCall | Falsy`` - a single call, also see `ChainCall`_. A call can be `Falsy`, as it is important to keep the same ordering of hooks even if in a given render cycle there might be not enough information to perform a call.
81
+
82
+
69
83
useChainCalls
70
84
=============
71
85
86
+
Makes multiple calls to specific contracts and returns values. The hook will cause the component to refresh when values change.
87
+
88
+
Calls will be combined into a single multicall across all uses of *useChainCall* and *useChainCalls*.
89
+
It is recommended to use `useContractCall`_ where applicable instead of this method.
90
+
72
91
*Parameters*
73
92
74
-
- ``calls: ChainCall[]``
93
+
- ``calls: ChainCall[]`` - list of calls, also see `ChainCall`_. Calls need to be in the same order across component renders.
94
+
95
+
useContractCall
96
+
===============
97
+
Makes a call to a specific contract and returns the value. The hook will cause the component to refresh when a new block is mined and the return value changes.
98
+
A syntax sugar for `useChainCall`_ that uses ABI, function name, and arguments instead of raw data.
99
+
100
+
**Parameters**
101
+
102
+
- ``calls: ContractCall | Falsy`` - a single call to a contract , also see `ContractCall`_
103
+
104
+
**Returns**
105
+
106
+
- ``any[] | undefined`` - the result of a call or undefined if call didn't return yet
107
+
108
+
useContractCalls
109
+
===============
110
+
Makes calls to specific contracts and returns values. The hook will cause the component to refresh when a new block is mined and the return values change.
111
+
A syntax sugar for `useChainCalls`_ that uses ABI, function name, and arguments instead of raw data.
112
+
113
+
**Parameters**
75
114
115
+
- ``calls: ContractCall[]`` - a single call to a contract , also see `ContractCall`_
116
+
117
+
**Returns**
118
+
119
+
- ``any[] | undefined`` - array of results of undefined if call didn't return yet
76
120
77
121
useConfig
78
122
=========
79
123
124
+
Returns singleton instance of `Config`_.
125
+
126
+
Function takes no parameters.
80
127
81
128
82
129
useDebounce
83
130
===========
84
131
132
+
Debounce a value of type T.
133
+
It stores a single value but returns after debounced time unless a new value is assigned before the debounce time elapses, in which case the process restarts.
134
+
85
135
**Generic parameters**
86
136
87
-
- ``T``
137
+
- ``T`` - type of stored value
88
138
89
139
**Parameters**
90
140
91
-
- delay: number
141
+
- ``value: T`` - variable to be debounced
142
+
- ``delay: number`` - debounce time - amount of time in ms
92
143
93
144
**Returns**
94
145
95
-
- ``T``
146
+
- ``T`` - debounced value
147
+
148
+
**Example**
149
+
150
+
.. code-block:: javascript
151
+
152
+
const [someValue, setValue] =useState(...)
153
+
constdebouncedValue=useDebounce(value, 1000)
154
+
96
155
97
156
useDebouncePair
98
157
===============
99
158
159
+
Debounce a pair of values of types T and U.
160
+
It stores a single value but returns after debounced time unless a new value is assigned before the debounce time elapses, in which case the process restarts.
161
+
162
+
This function is used for debouncing multicall until enough calls are aggregated.
163
+
164
+
100
165
**Generic parameters**
101
166
102
-
- ``T``
103
-
- ``U``
167
+
- ``T`` - type of first stored value
168
+
- ``U`` - type of second stored value
104
169
105
170
**Parameters**
106
171
107
-
- ``first: T``
108
-
- ``second: U``
109
-
- ``delay: number``
172
+
- ``first: T`` - first variable to be debounced
173
+
- ``second: U`` - second variable to be debounced
174
+
- ``delay: number`` - deboune time - amount of time in ms
110
175
111
176
**Returns**
112
177
113
-
- ``[T, U]``
178
+
- ``[T, U]`` - debounced values
179
+
180
+
useEtherBalance
181
+
===============
182
+
183
+
Returns ether balance of a given account.
184
+
185
+
**Parameters**
186
+
187
+
- ``address: string | Falsy`` - address of an account
188
+
189
+
**Returns**
190
+
191
+
- ``balance: BigNumber | undefined`` - a balance of the account which is BigNumber or *undefined* if not connected to network or address is a falsy value
Copy file name to clipboardExpand all lines: docs/source/getting-started.rst
+5-8Lines changed: 5 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ To get started, add following npm package :code:`@usedapp/core` to your project:
23
23
npm install @usedapp/core
24
24
25
25
Example
26
-
-----------------------
26
+
-------
27
27
28
28
Below is a simple example:
29
29
@@ -59,10 +59,12 @@ Below is a simple example:
59
59
}
60
60
61
61
62
-
Full example code is available `here <https://github.com/EthWorks/useDapp/tree/master/packages/example>`_.
62
+
Example is available `here <https://usedapp-example.netlify.app/>`_ and full example code is available `here <https://github.com/EthWorks/useDapp/tree/master/packages/example>`_.
63
63
64
+
Connecting to a network
65
+
-----------------------
64
66
65
-
First thing you need to do is set up **DAppPRovider** with optional config and wrap your whole App in it. You can read about config :ref:`here<config>`
67
+
The first thing you need to do is set up **DAppProvider** with optional config and wrap your whole App in it. You can read about config :ref:`here<config>`
66
68
67
69
.. code-block:: jsx
68
70
@@ -133,8 +135,3 @@ Can be used to fetch balance of ERC20 token specified by ``tokenAddress`` for pr
0 commit comments