22<!-- type: api reference -->
33<!-- summary: Reference for the Nimiq provider injected into mini apps -->
44
5- # Nimiq Provider API (window.nimiq)
5+ # Nimiq Provider API
66
77This provider exposes Nimiq blockchain operations and is injected into the mini app environment.
88
99## Access
1010
11- ``` javascript
12- const nimiq = window .nimiq
11+ Use the Mini App SDK ` init() ` helper to wait until Nimiq Pay injects the provider.
12+
13+ ``` ts
14+ import { init } from ' @nimiq/mini-app-sdk'
15+
16+ const nimiq = await init ()
1317```
1418
1519## Methods
@@ -36,7 +40,7 @@ Returns the user's Nimiq account addresses.
3640
3741** Example**
3842
39- ``` javascript
43+ ``` ts
4044const accounts = await nimiq .listAccounts ()
4145```
4246
@@ -62,7 +66,7 @@ Signs a message with the user's Nimiq key.
6266
6367** Example**
6468
65- ``` javascript
69+ ``` ts
6670const signed = await nimiq .sign (' hello' )
6771```
6872
@@ -84,7 +88,7 @@ Checks whether the Nimiq network consensus is established.
8488
8589** Example**
8690
87- ``` javascript
91+ ``` ts
8892const ready = await nimiq .isConsensusEstablished ()
8993```
9094
@@ -106,7 +110,7 @@ Returns the current Nimiq block height.
106110
107111** Example**
108112
109- ``` javascript
113+ ``` ts
110114const height = await nimiq .getBlockNumber ()
111115```
112116
@@ -119,6 +123,7 @@ Sends a basic NIM payment.
119123- ` recipient ` (string, required): Nimiq user-friendly address.
120124- ` value ` (number, required): amount in Luna (1 NIM = 100,000 Luna).
121125- ` fee ` (number, optional): transaction fee in Luna.
126+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
122127
123128** Returns**
124129
@@ -135,10 +140,14 @@ Sends a basic NIM payment.
135140
136141** Example**
137142
138- ``` javascript
143+ ``` ts
139144const txHash = await nimiq .sendBasicTransaction ({
140145 recipient: ' NQ07 0000 0000 0000 0000 0000 0000 0000 0000' ,
141146 value: 100000 ,
147+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
148+ fee: 1000 ,
149+ // Optional.
150+ validityStartHeight: 123456 ,
142151})
143152```
144153
@@ -151,7 +160,8 @@ Sends a NIM payment with an attached text message.
151160- ` recipient ` (string, required): Nimiq user-friendly address.
152161- ` value ` (number, required): amount in Luna (1 NIM = 100,000 Luna).
153162- ` fee ` (number, optional): transaction fee in Luna.
154- - ` data ` (string, optional): text message to attach.
163+ - ` data ` (string, required): text message to attach.
164+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
155165
156166** Returns**
157167
@@ -168,11 +178,15 @@ Sends a NIM payment with an attached text message.
168178
169179** Example**
170180
171- ``` javascript
181+ ``` ts
172182const txHash = await nimiq .sendBasicTransactionWithData ({
173183 recipient: ' NQ07 0000 0000 0000 0000 0000 0000 0000 0000' ,
174184 value: 100000 ,
175185 data: ' mic check' ,
186+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
187+ fee: 1000 ,
188+ // Optional.
189+ validityStartHeight: 123456 ,
176190})
177191```
178192
@@ -184,7 +198,8 @@ Creates a new staking transaction.
184198
185199- ` delegation ` (string, required): validator address or delegation target.
186200- ` value ` (number, required): amount in Luna.
187- - ` fee ` (number, required): transaction fee in Luna.
201+ - ` fee ` (number, optional): transaction fee in Luna.
202+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
188203
189204** Returns**
190205
@@ -201,22 +216,26 @@ Creates a new staking transaction.
201216
202217** Example**
203218
204- ``` javascript
219+ ``` ts
205220const txHash = await nimiq .sendNewStakerTransaction ({
206221 delegation: ' NQ07 0000 0000 0000 0000 0000 0000 0000 0000' ,
207222 value: 100000 ,
223+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
208224 fee: 1000 ,
225+ // Optional.
226+ validityStartHeight: 123456 ,
209227})
210228```
211229
212- ### ` sendAddStakeTransaction `
230+ ### ` sendStakeTransaction `
213231
214232Adds stake to an existing staker.
215233
216234** Parameters**
217235
218236- ` value ` (number, required): amount in Luna.
219- - ` fee ` (number, required): transaction fee in Luna.
237+ - ` fee ` (number, optional): transaction fee in Luna.
238+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
220239
221240** Returns**
222241
@@ -233,10 +252,13 @@ Adds stake to an existing staker.
233252
234253** Example**
235254
236- ``` javascript
237- const txHash = await nimiq .sendAddStakeTransaction ({
255+ ``` ts
256+ const txHash = await nimiq .sendStakeTransaction ({
238257 value: 100000 ,
258+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
239259 fee: 1000 ,
260+ // Optional.
261+ validityStartHeight: 123456 ,
240262})
241263```
242264
@@ -247,7 +269,8 @@ Sets the active stake amount.
247269** Parameters**
248270
249271- ` newActiveBalance ` (number, required): active stake amount in Luna.
250- - ` fee ` (number, required): transaction fee in Luna.
272+ - ` fee ` (number, optional): transaction fee in Luna.
273+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
251274
252275** Returns**
253276
@@ -264,10 +287,13 @@ Sets the active stake amount.
264287
265288** Example**
266289
267- ``` javascript
290+ ``` ts
268291const txHash = await nimiq .sendSetActiveStakeTransaction ({
269292 newActiveBalance: 100000 ,
293+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
270294 fee: 1000 ,
295+ // Optional.
296+ validityStartHeight: 123456 ,
271297})
272298```
273299
@@ -278,8 +304,9 @@ Updates staker settings.
278304** Parameters**
279305
280306- ` newDelegation ` (string, required): new validator address or delegation target.
281- - ` reactivateAllStake ` (boolean, required): whether to reactivate all stake.
282- - ` fee ` (number, required): transaction fee in Luna.
307+ - ` reactivateAllStake ` (boolean, optional): whether to reactivate all stake.
308+ - ` fee ` (number, optional): transaction fee in Luna.
309+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
283310
284311** Returns**
285312
@@ -296,11 +323,14 @@ Updates staker settings.
296323
297324** Example**
298325
299- ``` javascript
326+ ``` ts
300327const txHash = await nimiq .sendUpdateStakerTransaction ({
301328 newDelegation: ' NQ07 0000 0000 0000 0000 0000 0000 0000 0000' ,
302329 reactivateAllStake: true ,
330+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
303331 fee: 1000 ,
332+ // Optional.
333+ validityStartHeight: 123456 ,
304334})
305335```
306336
@@ -311,7 +341,8 @@ Retires stake from a staker.
311341** Parameters**
312342
313343- ` retireStake ` (number, required): amount in Luna to retire.
314- - ` fee ` (number, required): transaction fee in Luna.
344+ - ` fee ` (number, optional): transaction fee in Luna.
345+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
315346
316347** Returns**
317348
@@ -328,10 +359,13 @@ Retires stake from a staker.
328359
329360** Example**
330361
331- ``` javascript
362+ ``` ts
332363const txHash = await nimiq .sendRetireStakeTransaction ({
333364 retireStake: 100000 ,
365+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
334366 fee: 1000 ,
367+ // Optional.
368+ validityStartHeight: 123456 ,
335369})
336370```
337371
@@ -342,7 +376,8 @@ Removes stake from a staker.
342376** Parameters**
343377
344378- ` value ` (number, required): amount in Luna.
345- - ` fee ` (number, required): transaction fee in Luna.
379+ - ` fee ` (number, optional): transaction fee in Luna.
380+ - ` validityStartHeight ` (number, optional): block height from which the transaction becomes valid.
346381
347382** Returns**
348383
@@ -359,9 +394,12 @@ Removes stake from a staker.
359394
360395** Example**
361396
362- ``` javascript
397+ ``` ts
363398const txHash = await nimiq .sendRemoveStakeTransaction ({
364399 value: 100000 ,
400+ // Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
365401 fee: 1000 ,
402+ // Optional.
403+ validityStartHeight: 123456 ,
366404})
367405```
0 commit comments