@@ -6,6 +6,8 @@ To make your zkApp compatible with Mina wallets, we've created a strongly typed
6
6
7
7
### mina_accounts
8
8
9
+ Get accounts. If not authorized, the response is an empty array.
10
+
9
11
``` ts twoslash
10
12
import { createStore } from ' @mina-js/connect'
11
13
@@ -14,8 +16,22 @@ const { provider } = store.getProviders()[0]
14
16
const { result } = await provider .request <' mina_accounts' >({ method: ' mina_accounts' })
15
17
```
16
18
19
+ ### mina_requestAccounts
20
+
21
+ Acts like ` mina_accounts ` but with a prompt to authorize in case user didn't authorize yet.
22
+
23
+ ``` ts twoslash
24
+ import { createStore } from ' @mina-js/connect'
25
+
26
+ const store = createStore ()
27
+ const { provider } = store .getProviders ()[0 ]
28
+ const { result } = await provider .request <' mina_requestAccounts' >({ method: ' mina_requestAccounts' })
29
+ ```
30
+
17
31
### mina_chainId
18
32
33
+ Get the chain ID. It's a string that represents the current network. Values are ` mina:mainnet ` or ` mina:testnet ` .
34
+
19
35
``` ts twoslash
20
36
import { createStore } from ' @mina-js/connect'
21
37
@@ -26,6 +42,8 @@ const { result } = await provider.request<'mina_chainId'>({ method: 'mina_chainI
26
42
27
43
### mina_getBalance
28
44
45
+ Get the balance of the current account. The value is already parsed to Mina units.
46
+
29
47
``` ts twoslash
30
48
import { createStore } from ' @mina-js/connect'
31
49
@@ -36,6 +54,8 @@ const { result } = await provider.request<'mina_getBalance'>({ method: 'mina_get
36
54
37
55
### mina_chainInformation
38
56
57
+ Get chain information. Similar to ` mina_chainId ` , but more detailed. It returns current network's RPC url, name, and slug (chain ID).
58
+
39
59
``` ts twoslash
40
60
import { createStore } from ' @mina-js/connect'
41
61
@@ -44,6 +64,21 @@ const { provider } = store.getProviders()[0]
44
64
const { result } = await provider .request <' mina_chainInformation' >({ method: ' mina_chainInformation' })
45
65
```
46
66
67
+ ### mina_getState
68
+
69
+ Returns filtered Public Credentials.
70
+
71
+ ``` ts twoslash
72
+ import { createStore } from ' @mina-js/connect'
73
+
74
+ const store = createStore ()
75
+ const { provider } = store .getProviders ()[0 ]
76
+ const { result } = await provider .request <' mina_getState' >({
77
+ method: ' mina_getState' ,
78
+ params: [{ issuer: " University of Example" }, []],
79
+ })
80
+ ```
81
+
47
82
## Commands
48
83
49
84
### mina_sign
@@ -128,3 +163,74 @@ const { result } = await provider.request<'mina_createNullifier'>({
128
163
params: [[' 1' , ' 2' , ' 3' ]]
129
164
})
130
165
```
166
+
167
+ ### mina_sendTransaction
168
+
169
+ Send a signed transaction to the network.
170
+
171
+ ``` ts twoslash
172
+ import { createStore } from ' @mina-js/connect'
173
+
174
+ const store = createStore ()
175
+ const { provider } = store .getProviders ()[0 ]
176
+ const { result } = await provider .request <' mina_sendTransaction' >({
177
+ method: ' mina_sendTransaction' ,
178
+ params: [{ input: {}, signature: { field: ' xyz' , scalar: ' xyz' } }, ' payment' ]
179
+ })
180
+ ```
181
+
182
+ ### mina_setState
183
+
184
+ Saves a new Public Credential.
185
+
186
+ ``` ts twoslash
187
+ import { createStore } from ' @mina-js/connect'
188
+
189
+ const store = createStore ()
190
+ const { provider } = store .getProviders ()[0 ]
191
+ const { result } = await provider .request <' mina_setState' >({
192
+ method: " mina_setState" ,
193
+ params: [
194
+ {
195
+ objectName: " Pallad Mock Credential" ,
196
+ object: {}, // DID Credential with a Kimchi proof
197
+ },
198
+ ],
199
+ })
200
+ ```
201
+
202
+ ### mina_switchChain
203
+
204
+ Prompts user to switch to another network. It's useful for dApps that support multiple networks.
205
+
206
+ ``` ts twoslash
207
+ import { createStore } from ' @mina-js/connect'
208
+
209
+ const store = createStore ()
210
+ const { provider } = store .getProviders ()[0 ]
211
+ await provider .request <' mina_switchChain' >({
212
+ method: ' mina_switchChain' ,
213
+ params: [' mina:mainnet' ]
214
+ })
215
+ ```
216
+
217
+ ### mina_addChain
218
+
219
+ Prompts user to add a new chain.
220
+
221
+ ``` ts twoslash
222
+ import { createStore } from ' @mina-js/connect'
223
+
224
+ const store = createStore ()
225
+ const { provider } = store .getProviders ()[0 ]
226
+ await provider .request <' mina_addChain' >({
227
+ method: ' mina_addChain' ,
228
+ params: [
229
+ {
230
+ name: ' Mina Fakenet' ,
231
+ slug: ' mina:fakenet' ,
232
+ url: ' https://fakenet.example.com' ,
233
+ }
234
+ ]
235
+ })
236
+ ```
0 commit comments