Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mini-apps/api-reference/ethereum-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- type: api reference -->
<!-- summary: Reference for the EIP-1193 Ethereum provider injected into mini apps, including EIP-6963 compatibility -->

# Ethereum Provider API (window.ethereum)
# Ethereum Provider API

This provider implements [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) and supports [EIP-6963](https://eips.ethereum.org/EIPS/eip-6963) provider discovery. It is injected into the mini app environment.

Expand Down
13 changes: 7 additions & 6 deletions mini-apps/api-reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# API Reference

This API is injected by the host app into the mini app environment. The providers are available on the `window` object. This section is reference-only.
This API is injected by the host app into the mini app environment. For Nimiq access, the recommended pattern is to use the Mini App SDK `init()` helper. This section is reference-only.

## Contents

Expand All @@ -17,14 +17,15 @@ To load and build a mini app, see [Load a Local Mini App in Nimiq Pay](https://n

### Nimiq Provider

```javascript
const nimiq = window.nimiq
```typescript
import { init } from '@nimiq/mini-app-sdk'

const accounts = await nimiq.listAccounts()
const address = accounts[0]
const nimiq = await init()

const accounts = await nimiq.listAccounts()
const signed = await nimiq.sign('hello')
console.log({ address, signed })

console.log({ accounts, signed })
```

### Ethereum dApp (EIP-1193)
Expand Down
44 changes: 26 additions & 18 deletions mini-apps/api-reference/nimiq-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
<!-- type: api reference -->
<!-- summary: Reference for the Nimiq provider injected into mini apps -->

# Nimiq Provider API (window.nimiq)
# Nimiq Provider API

This provider exposes Nimiq blockchain operations and is injected into the mini app environment.

## Access

```javascript
const nimiq = window.nimiq
Use the Mini App SDK `init()` helper to wait until Nimiq Pay injects the provider.

```ts
import { init } from '@nimiq/mini-app-sdk'

const nimiq = await init()
```

## Methods
Expand All @@ -36,7 +40,7 @@ Returns the user's Nimiq account addresses.

**Example**

```javascript
```ts
const accounts = await nimiq.listAccounts()
```

Expand All @@ -62,7 +66,7 @@ Signs a message with the user's Nimiq key.

**Example**

```javascript
```ts
const signed = await nimiq.sign('hello')
```

Expand All @@ -84,7 +88,7 @@ Checks whether the Nimiq network consensus is established.

**Example**

```javascript
```ts
const ready = await nimiq.isConsensusEstablished()
```

Expand All @@ -106,7 +110,7 @@ Returns the current Nimiq block height.

**Example**

```javascript
```ts
const height = await nimiq.getBlockNumber()
```

Expand Down Expand Up @@ -135,7 +139,7 @@ Sends a basic NIM payment.

**Example**

```javascript
```ts
const txHash = await nimiq.sendBasicTransaction({
recipient: 'NQ07 0000 0000 0000 0000 0000 0000 0000 0000',
value: 100000,
Expand Down Expand Up @@ -168,7 +172,7 @@ Sends a NIM payment with an attached text message.

**Example**

```javascript
```ts
const txHash = await nimiq.sendBasicTransactionWithData({
recipient: 'NQ07 0000 0000 0000 0000 0000 0000 0000 0000',
value: 100000,
Expand Down Expand Up @@ -201,22 +205,23 @@ Creates a new staking transaction.

**Example**

```javascript
```ts
const txHash = await nimiq.sendNewStakerTransaction({
delegation: 'NQ07 0000 0000 0000 0000 0000 0000 0000 0000',
value: 100000,
fee: 1000,
})
```

### `sendAddStakeTransaction`
### `sendStakeTransaction`

Adds stake to an existing staker.

**Parameters**

- `value` (number, required): amount in Luna.
- `fee` (number, required): transaction fee in Luna.
- `fee` (number, optional): transaction fee in Luna.
- `validityStartHeight` (number, optional): block height from which the transaction becomes valid.

**Returns**

Expand All @@ -233,10 +238,13 @@ Adds stake to an existing staker.

**Example**

```javascript
const txHash = await nimiq.sendAddStakeTransaction({
```ts
const txHash = await nimiq.sendStakeTransaction({
value: 100000,
// Optional. Nimiq Pay chooses a fee automatically, using 0 if possible.
fee: 1000,
// Optional.
validityStartHeight: 123456,
})
```

Expand Down Expand Up @@ -264,7 +272,7 @@ Sets the active stake amount.

**Example**

```javascript
```ts
const txHash = await nimiq.sendSetActiveStakeTransaction({
newActiveBalance: 100000,
fee: 1000,
Expand Down Expand Up @@ -296,7 +304,7 @@ Updates staker settings.

**Example**

```javascript
```ts
const txHash = await nimiq.sendUpdateStakerTransaction({
newDelegation: 'NQ07 0000 0000 0000 0000 0000 0000 0000 0000',
reactivateAllStake: true,
Expand Down Expand Up @@ -328,7 +336,7 @@ Retires stake from a staker.

**Example**

```javascript
```ts
const txHash = await nimiq.sendRetireStakeTransaction({
retireStake: 100000,
fee: 1000,
Expand Down Expand Up @@ -359,7 +367,7 @@ Removes stake from a staker.

**Example**

```javascript
```ts
const txHash = await nimiq.sendRemoveStakeTransaction({
value: 100000,
fee: 1000,
Expand Down
Loading
Loading