@provablehq/sdk 0.6.13 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +16 -16
  2. package/dist/{account.d.ts → mainnet/account.d.ts} +3 -3
  3. package/dist/{index.d.ts → mainnet/browser.d.ts} +5 -4
  4. package/dist/mainnet/browser.js +3127 -0
  5. package/dist/mainnet/browser.js.map +1 -0
  6. package/dist/{function-key-provider.d.ts → mainnet/function-key-provider.d.ts} +57 -57
  7. package/dist/{network-client.d.ts → mainnet/network-client.d.ts} +26 -26
  8. package/dist/{node-polyfill.d.ts → mainnet/node-polyfill.d.ts} +1 -0
  9. package/dist/{node-polyfill.js → mainnet/node-polyfill.js} +1 -0
  10. package/dist/mainnet/node-polyfill.js.map +1 -0
  11. package/dist/mainnet/node.d.ts +2 -0
  12. package/dist/{node.js → mainnet/node.js} +3 -2
  13. package/dist/{node.js.map → mainnet/node.js.map} +1 -1
  14. package/dist/{offline-key-provider.d.ts → mainnet/offline-key-provider.d.ts} +22 -22
  15. package/dist/mainnet/polyfill/shared.d.ts +1 -0
  16. package/dist/{program-manager.d.ts → mainnet/program-manager.d.ts} +59 -59
  17. package/dist/{record-provider.d.ts → mainnet/record-provider.d.ts} +22 -22
  18. package/dist/{utils.d.ts → mainnet/utils.d.ts} +1 -0
  19. package/dist/{worker.d.ts → mainnet/worker.d.ts} +2 -1
  20. package/dist/mainnet/worker.js +78 -0
  21. package/dist/mainnet/worker.js.map +1 -0
  22. package/dist/testnet/account.d.ts +137 -0
  23. package/dist/testnet/browser.d.ts +53 -0
  24. package/dist/{index.js → testnet/browser.js} +197 -186
  25. package/dist/testnet/browser.js.map +1 -0
  26. package/dist/testnet/function-key-provider.d.ts +348 -0
  27. package/dist/testnet/managed-worker.d.ts +3 -0
  28. package/dist/testnet/models/block.d.ts +21 -0
  29. package/dist/testnet/models/confirmed_transaction.d.ts +6 -0
  30. package/dist/testnet/models/execution.d.ts +5 -0
  31. package/dist/testnet/models/input.d.ts +10 -0
  32. package/dist/testnet/models/output.d.ts +6 -0
  33. package/dist/testnet/models/transactionModel.d.ts +6 -0
  34. package/dist/testnet/models/transition.d.ts +13 -0
  35. package/dist/testnet/network-client.d.ts +267 -0
  36. package/dist/testnet/node-polyfill.d.ts +5 -0
  37. package/dist/testnet/node-polyfill.js +303 -0
  38. package/dist/testnet/node-polyfill.js.map +1 -0
  39. package/dist/testnet/node.d.ts +2 -0
  40. package/dist/testnet/node.js +12 -0
  41. package/dist/testnet/node.js.map +1 -0
  42. package/dist/testnet/offline-key-provider.d.ts +347 -0
  43. package/dist/testnet/polyfill/crypto.d.ts +1 -0
  44. package/dist/testnet/polyfill/fetch.d.ts +1 -0
  45. package/dist/testnet/polyfill/shared.d.ts +1 -0
  46. package/dist/testnet/polyfill/worker.d.ts +1 -0
  47. package/dist/testnet/polyfill/xmlhttprequest.d.ts +1 -0
  48. package/dist/testnet/program-manager.d.ts +636 -0
  49. package/dist/testnet/record-provider.d.ts +236 -0
  50. package/dist/testnet/utils.d.ts +3 -0
  51. package/dist/testnet/worker.d.ts +9 -0
  52. package/dist/testnet/worker.js +78 -0
  53. package/dist/testnet/worker.js.map +1 -0
  54. package/package.json +23 -13
  55. package/dist/index.js.map +0 -1
  56. package/dist/node-polyfill.js.map +0 -1
  57. package/dist/node.d.ts +0 -2
  58. package/dist/worker.js +0 -74
  59. package/dist/worker.js.map +0 -1
  60. /package/dist/{managed-worker.d.ts → mainnet/managed-worker.d.ts} +0 -0
  61. /package/dist/{models → mainnet/models}/block.d.ts +0 -0
  62. /package/dist/{models → mainnet/models}/confirmed_transaction.d.ts +0 -0
  63. /package/dist/{models → mainnet/models}/execution.d.ts +0 -0
  64. /package/dist/{models → mainnet/models}/input.d.ts +0 -0
  65. /package/dist/{models → mainnet/models}/output.d.ts +0 -0
  66. /package/dist/{models → mainnet/models}/transactionModel.d.ts +0 -0
  67. /package/dist/{models → mainnet/models}/transition.d.ts +0 -0
  68. /package/dist/{polyfill → mainnet/polyfill}/crypto.d.ts +0 -0
  69. /package/dist/{polyfill → mainnet/polyfill}/fetch.d.ts +0 -0
  70. /package/dist/{polyfill → mainnet/polyfill}/worker.d.ts +0 -0
  71. /package/dist/{polyfill → mainnet/polyfill}/xmlhttprequest.d.ts +0 -0
@@ -0,0 +1,636 @@
1
+ import { Account, AleoNetworkClient, ExecutionResponse, FunctionKeyProvider, FunctionKeyPair, OfflineQuery, KeySearchParams, RecordPlaintext, RecordProvider, RecordSearchParams, PrivateKey, Program, ProgramImports, ProvingKey, VerifyingKey, Transaction } from "./browser";
2
+ /**
3
+ * Represents the options for executing a transaction in the Aleo network.
4
+ * This interface is used to specify the parameters required for building and submitting an execution transaction.
5
+ *
6
+ * @property {string} programName - The name of the program containing the function to be executed.
7
+ * @property {string} functionName - The name of the function to execute within the program.
8
+ * @property {number} fee - The fee to be paid for the transaction.
9
+ * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
10
+ * @property {string[]} inputs - The inputs to the function being executed.
11
+ * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.
12
+ * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.
13
+ * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.
14
+ * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.
15
+ * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.
16
+ * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.
17
+ * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.
18
+ * @property {string | Program} [program] - Optional program source code to use for the transaction.
19
+ * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
20
+ */
21
+ interface ExecuteOptions {
22
+ programName: string;
23
+ functionName: string;
24
+ fee: number;
25
+ privateFee: boolean;
26
+ inputs: string[];
27
+ recordSearchParams?: RecordSearchParams;
28
+ keySearchParams?: KeySearchParams;
29
+ feeRecord?: string | RecordPlaintext;
30
+ provingKey?: ProvingKey;
31
+ verifyingKey?: VerifyingKey;
32
+ privateKey?: PrivateKey;
33
+ offlineQuery?: OfflineQuery;
34
+ program?: string | Program;
35
+ imports?: ProgramImports;
36
+ }
37
+ /**
38
+ * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
39
+ */
40
+ declare class ProgramManager {
41
+ account: Account | undefined;
42
+ keyProvider: FunctionKeyProvider;
43
+ host: string;
44
+ networkClient: AleoNetworkClient;
45
+ recordProvider: RecordProvider | undefined;
46
+ /** Create a new instance of the ProgramManager
47
+ *
48
+ * @param { string | undefined } host A host uri running the official Aleo API
49
+ * @param { FunctionKeyProvider | undefined } keyProvider A key provider that implements {@link FunctionKeyProvider} interface
50
+ * @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface
51
+ */
52
+ constructor(host?: string | undefined, keyProvider?: FunctionKeyProvider | undefined, recordProvider?: RecordProvider | undefined);
53
+ /**
54
+ * Set the account to use for transaction submission to the Aleo network
55
+ *
56
+ * @param {Account} account Account to use for transaction submission
57
+ */
58
+ setAccount(account: Account): void;
59
+ /**
60
+ * Set the key provider that provides the proving and verifying keys for programs
61
+ *
62
+ * @param {FunctionKeyProvider} keyProvider
63
+ */
64
+ setKeyProvider(keyProvider: FunctionKeyProvider): void;
65
+ /**
66
+ * Set the host peer to use for transaction submission to the Aleo network
67
+ *
68
+ * @param host {string} Peer url to use for transaction submission
69
+ */
70
+ setHost(host: string): void;
71
+ /**
72
+ * Set the record provider that provides records for transactions
73
+ *
74
+ * @param {RecordProvider} recordProvider
75
+ */
76
+ setRecordProvider(recordProvider: RecordProvider): void;
77
+ /**
78
+ * Deploy an Aleo program to the Aleo network
79
+ *
80
+ * @param {string} program Program source code
81
+ * @param {number} fee Fee to pay for the transaction
82
+ * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
83
+ * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for searching for a record to use
84
+ * pay the deployment fee
85
+ * @param {string | RecordPlaintext | undefined} feeRecord Optional Fee record to use for the transaction
86
+ * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction
87
+ * @returns {string} The transaction id of the deployed program or a failure message from the network
88
+ *
89
+ * @example
90
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider
91
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
92
+ * const keyProvider = new AleoKeyProvider();
93
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
94
+ *
95
+ * // Initialize a program manager with the key provider to automatically fetch keys for deployments
96
+ * const program = "program hello_hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
97
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
98
+ *
99
+ * // Define a fee in credits
100
+ * const fee = 1.2;
101
+ *
102
+ * // Deploy the program
103
+ * const tx_id = await programManager.deploy(program, fee);
104
+ *
105
+ * // Verify the transaction was successful
106
+ * const transaction = await programManager.networkClient.getTransaction(tx_id);
107
+ */
108
+ deploy(program: string, fee: number, privateFee: boolean, recordSearchParams?: RecordSearchParams, feeRecord?: string | RecordPlaintext, privateKey?: PrivateKey): Promise<string>;
109
+ /**
110
+ * Builds an execution transaction for submission to the Aleo network.
111
+ *
112
+ * @param {ExecuteOptions} options - The options for the execution transaction.
113
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
114
+ *
115
+ * @example
116
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
117
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
118
+ * const keyProvider = new AleoKeyProvider();
119
+ * keyProvider.useCache = true;
120
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
121
+ *
122
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions
123
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
124
+ *
125
+ * // Build and execute the transaction
126
+ * const transaction = await programManager.buildExecutionTransaction({
127
+ * programName: "hello_hello.aleo",
128
+ * functionName: "hello_hello",
129
+ * fee: 0.020,
130
+ * privateFee: false,
131
+ * inputs: ["5u32", "5u32"],
132
+ * keySearchParams: { "cacheKey": "hello_hello:hello" }
133
+ * });
134
+ * const result = await programManager.networkClient.submitTransaction(transaction);
135
+ */
136
+ buildExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
137
+ /**
138
+ * Builds an execution transaction for submission to the Aleo network.
139
+ *
140
+ * @param {ExecuteOptions} options - The options for the execution transaction.
141
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
142
+ *
143
+ * @example
144
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
145
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
146
+ * const keyProvider = new AleoKeyProvider();
147
+ * keyProvider.useCache = true;
148
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
149
+ *
150
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions
151
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
152
+ *
153
+ * // Build and execute the transaction
154
+ * const transaction = await programManager.execute({
155
+ * programName: "hello_hello.aleo",
156
+ * functionName: "hello_hello",
157
+ * fee: 0.020,
158
+ * privateFee: false,
159
+ * inputs: ["5u32", "5u32"],
160
+ * keySearchParams: { "cacheKey": "hello_hello:hello" }
161
+ * });
162
+ * const result = await programManager.networkClient.submitTransaction(transaction);
163
+ */
164
+ execute(options: ExecuteOptions): Promise<string>;
165
+ /**
166
+ * Run an Aleo program in offline mode
167
+ *
168
+ * @param {string} program Program source code containing the function to be executed
169
+ * @param {string} function_name Function name to execute
170
+ * @param {string[]} inputs Inputs to the function
171
+ * @param {number} proveExecution Whether to prove the execution of the function and return an execution transcript
172
+ * that contains the proof.
173
+ * @param {string[] | undefined} imports Optional imports to the program
174
+ * @param {KeySearchParams | undefined} keySearchParams Optional parameters for finding the matching proving &
175
+ * verifying keys for the function
176
+ * @param {ProvingKey | undefined} provingKey Optional proving key to use for the transaction
177
+ * @param {VerifyingKey | undefined} verifyingKey Optional verifying key to use for the transaction
178
+ * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction
179
+ * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
180
+ * @returns {Promise<string>}
181
+ *
182
+ * @example
183
+ * import { Account, Program } from '@provablehq/sdk';
184
+ *
185
+ * /// Create the source for the "helloworld" program
186
+ * const program = "program helloworld.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n";
187
+ * const programManager = new ProgramManager();
188
+ *
189
+ * /// Create a temporary account for the execution of the program
190
+ * const account = new Account();
191
+ * programManager.setAccount(account);
192
+ *
193
+ * /// Get the response and ensure that the program executed correctly
194
+ * const executionResponse = await programManager.run(program, "hello", ["5u32", "5u32"]);
195
+ * const result = executionResponse.getOutputs();
196
+ * assert(result === ["10u32"]);
197
+ */
198
+ run(program: string, function_name: string, inputs: string[], proveExecution: boolean, imports?: ProgramImports, keySearchParams?: KeySearchParams, provingKey?: ProvingKey, verifyingKey?: VerifyingKey, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<ExecutionResponse>;
199
+ /**
200
+ * Join two credits records into a single credits record
201
+ *
202
+ * @param {RecordPlaintext | string} recordOne First credits record to join
203
+ * @param {RecordPlaintext | string} recordTwo Second credits record to join
204
+ * @param {number} fee Fee in credits pay for the join transaction
205
+ * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
206
+ * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the fee record to use
207
+ * to pay the fee for the join transaction
208
+ * @param {RecordPlaintext | string | undefined} feeRecord Fee record to use for the join transaction
209
+ * @param {PrivateKey | undefined} privateKey Private key to use for the join transaction
210
+ * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
211
+ * @returns {Promise<string>}
212
+ */
213
+ join(recordOne: RecordPlaintext | string, recordTwo: RecordPlaintext | string, fee: number, privateFee: boolean, recordSearchParams?: RecordSearchParams | undefined, feeRecord?: RecordPlaintext | string | undefined, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<string>;
214
+ /**
215
+ * Split credits into two new credits records
216
+ *
217
+ * @param {number} splitAmount Amount in microcredits to split from the original credits record
218
+ * @param {RecordPlaintext | string} amountRecord Amount record to use for the split transaction
219
+ * @param {PrivateKey | undefined} privateKey Optional private key to use for the split transaction
220
+ * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
221
+ * @returns {Promise<string>}
222
+ *
223
+ * @example
224
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider
225
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
226
+ * const keyProvider = new AleoKeyProvider();
227
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
228
+ *
229
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions
230
+ * const programName = "hello_hello.aleo";
231
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
232
+ * const record = "{ owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private, microcredits: 45000000u64.private, _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
233
+ * const tx_id = await programManager.split(25000000, record);
234
+ * const transaction = await programManager.networkClient.getTransaction(tx_id);
235
+ */
236
+ split(splitAmount: number, amountRecord: RecordPlaintext | string, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<string>;
237
+ /**
238
+ * Pre-synthesize proving and verifying keys for a program
239
+ *
240
+ * @param program {string} The program source code to synthesize keys for
241
+ * @param function_id {string} The function id to synthesize keys for
242
+ * @param inputs {Array<string>} Sample inputs to the function
243
+ * @param privateKey {PrivateKey | undefined} Optional private key to use for the key synthesis
244
+ *
245
+ * @returns {Promise<FunctionKeyPair>}
246
+ */
247
+ synthesizeKeys(program: string, function_id: string, inputs: Array<string>, privateKey?: PrivateKey): Promise<FunctionKeyPair>;
248
+ /**
249
+ * Build a transaction to transfer credits to another account for later submission to the Aleo network
250
+ *
251
+ * @param {number} amount The amount of credits to transfer
252
+ * @param {string} recipient The recipient of the transfer
253
+ * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
254
+ * @param {number} fee The fee to pay for the transfer
255
+ * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
256
+ * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
257
+ * records for the transfer transaction
258
+ * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
259
+ * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
260
+ * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
261
+ * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
262
+ * @returns {Promise<string>} The transaction id of the transfer transaction
263
+ *
264
+ * @example
265
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider
266
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
267
+ * const keyProvider = new AleoKeyProvider();
268
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
269
+ *
270
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions
271
+ * const programName = "hello_hello.aleo";
272
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
273
+ * await programManager.initialize();
274
+ * const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
275
+ * const transaction = await programManager.networkClient.getTransaction(tx_id);
276
+ */
277
+ buildTransferTransaction(amount: number, recipient: string, transferType: string, fee: number, privateFee: boolean, recordSearchParams?: RecordSearchParams, amountRecord?: RecordPlaintext | string, feeRecord?: RecordPlaintext | string, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<Transaction>;
278
+ /**
279
+ * Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network
280
+ *
281
+ * @param {number} amount The amount of credits to transfer
282
+ * @param {string} recipient The recipient of the transfer
283
+ * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
284
+ * @param {number} fee The fee to pay for the transfer
285
+ * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
286
+ * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
287
+ * records for the transfer transaction
288
+ * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
289
+ * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
290
+ * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
291
+ * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
292
+ * @returns {Promise<string>} The transaction id of the transfer transaction
293
+ */
294
+ buildTransferPublicTransaction(amount: number, recipient: string, fee: number, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<Transaction>;
295
+ /**
296
+ * Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network
297
+ *
298
+ * @param {number} amount The amount of credits to transfer
299
+ * @param {string} recipient The recipient of the transfer
300
+ * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
301
+ * @param {number} fee The fee to pay for the transfer
302
+ * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
303
+ * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
304
+ * records for the transfer transaction
305
+ * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
306
+ * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
307
+ * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
308
+ * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
309
+ * @returns {Promise<string>} The transaction id of the transfer transaction
310
+ */
311
+ buildTransferPublicAsSignerTransaction(amount: number, recipient: string, fee: number, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<Transaction>;
312
+ /**
313
+ * Transfer credits to another account
314
+ *
315
+ * @param {number} amount The amount of credits to transfer
316
+ * @param {string} recipient The recipient of the transfer
317
+ * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
318
+ * @param {number} fee The fee to pay for the transfer
319
+ * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
320
+ * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
321
+ * records for the transfer transaction
322
+ * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
323
+ * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
324
+ * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
325
+ * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
326
+ * @returns {Promise<string>} The transaction id of the transfer transaction
327
+ *
328
+ * @example
329
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider
330
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
331
+ * const keyProvider = new AleoKeyProvider();
332
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
333
+ *
334
+ * // Initialize a program manager with the key provider to automatically fetch keys for executions
335
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
336
+ * await programManager.initialize();
337
+ * const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
338
+ * const transaction = await programManager.networkClient.getTransaction(tx_id);
339
+ */
340
+ transfer(amount: number, recipient: string, transferType: string, fee: number, privateFee: boolean, recordSearchParams?: RecordSearchParams, amountRecord?: RecordPlaintext | string, feeRecord?: RecordPlaintext | string, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<string>;
341
+ /**
342
+ * Build transaction to bond credits to a validator for later submission to the Aleo Network
343
+ *
344
+ * @example
345
+ * // Create a keyProvider to handle key management
346
+ * const keyProvider = new AleoKeyProvider();
347
+ * keyProvider.useCache = true;
348
+ *
349
+ * // Create a new ProgramManager with the key that will be used to bond credits
350
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
351
+ * programManager.setAccount(new Account("YourPrivateKey"));
352
+ *
353
+ * // Create the bonding transaction object for later submission
354
+ * const tx = await programManager.buildBondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
355
+ * console.log(tx);
356
+ *
357
+ * // The transaction can be later submitted to the network using the network client.
358
+ * const result = await programManager.networkClient.submitTransaction(tx);
359
+ *
360
+ * @returns string
361
+ * @param {string} staker_address Address of the staker who is bonding the credits
362
+ * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the
363
+ * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
364
+ * requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing
365
+ * validator and is different from the address of the executor of this function, it will bond the credits to that
366
+ * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
367
+ * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
368
+ * @param {number} amount The amount of credits to bond
369
+ * @param {Partial<ExecuteOptions>} options - Override default execution options.
370
+ */
371
+ buildBondPublicTransaction(staker_address: string, validator_address: string, withdrawal_address: string, amount: number, options?: Partial<ExecuteOptions>): Promise<Transaction>;
372
+ /**
373
+ * Bond credits to validator.
374
+ *
375
+ * @example
376
+ * // Create a keyProvider to handle key management
377
+ * const keyProvider = new AleoKeyProvider();
378
+ * keyProvider.useCache = true;
379
+ *
380
+ * // Create a new ProgramManager with the key that will be used to bond credits
381
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
382
+ * programManager.setAccount(new Account("YourPrivateKey"));
383
+ *
384
+ * // Create the bonding transaction
385
+ * const tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
386
+ *
387
+ * @returns string
388
+ * @param {string} staker_address Address of the staker who is bonding the credits
389
+ * @param {string} validator_address Address of the validator to bond to, if this address is the same as the signer (i.e. the
390
+ * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
391
+ * requires a minimum of 1,000,000 credits to bond (subject to change). If the address is specified is an existing
392
+ * validator and is different from the address of the executor of this function, it will bond the credits to that
393
+ * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
394
+ * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
395
+ * @param {number} amount The amount of credits to bond
396
+ * @param {Options} options Options for the execution
397
+ */
398
+ bondPublic(staker_address: string, validator_address: string, withdrawal_address: string, amount: number, options?: Partial<ExecuteOptions>): Promise<string>;
399
+ /**
400
+ * Build a bond_validator transaction for later submission to the Aleo Network.
401
+ *
402
+ * @example
403
+ * // Create a keyProvider to handle key management
404
+ * const keyProvider = new AleoKeyProvider();
405
+ * keyProvider.useCache = true;
406
+ *
407
+ * // Create a new ProgramManager with the key that will be used to bond credits
408
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
409
+ * programManager.setAccount(new Account("YourPrivateKey"));
410
+ *
411
+ * // Create the bond validator transaction object for later use.
412
+ * const tx = await programManager.buildBondValidatorTransaction("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
413
+ * console.log(tx);
414
+ *
415
+ * // The transaction can later be submitted to the network using the network client.
416
+ * const tx_id = await programManager.networkClient.submitTransaction(tx);
417
+ *
418
+ * @returns string
419
+ * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the
420
+ * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
421
+ * requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing
422
+ * validator and is different from the address of the executor of this function, it will bond the credits to that
423
+ * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
424
+ * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
425
+ * @param {number} amount The amount of credits to bond
426
+ * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
427
+ * @param {Partial<ExecuteOptions>} options - Override default execution options.
428
+ */
429
+ buildBondValidatorTransaction(validator_address: string, withdrawal_address: string, amount: number, commission: number, options?: Partial<ExecuteOptions>): Promise<Transaction>;
430
+ /**
431
+ * Build transaction to bond a validator.
432
+ *
433
+ * @example
434
+ * // Create a keyProvider to handle key management
435
+ * const keyProvider = new AleoKeyProvider();
436
+ * keyProvider.useCache = true;
437
+ *
438
+ * // Create a new ProgramManager with the key that will be used to bond credits
439
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
440
+ * programManager.setAccount(new Account("YourPrivateKey"));
441
+ *
442
+ * // Create the bonding transaction
443
+ * const tx_id = await programManager.bondValidator("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
444
+ *
445
+ * @returns string
446
+ * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the
447
+ * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
448
+ * requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing
449
+ * validator and is different from the address of the executor of this function, it will bond the credits to that
450
+ * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
451
+ * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
452
+ * @param {number} amount The amount of credits to bond
453
+ * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
454
+ * @param {Partial<ExecuteOptions>} options - Override default execution options.
455
+ */
456
+ bondValidator(validator_address: string, withdrawal_address: string, amount: number, commission: number, options?: Partial<ExecuteOptions>): Promise<string>;
457
+ /**
458
+ * Build a transaction to unbond public credits from a validator in the Aleo network.
459
+ *
460
+ * @param {string} staker_address - The address of the staker who is unbonding the credits.
461
+ * @param {number} amount - The amount of credits to unbond (scaled by 1,000,000).
462
+ * @param {Partial<ExecuteOptions>} options - Override default execution options.
463
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.
464
+ *
465
+ * @example
466
+ * // Create a keyProvider to handle key management.
467
+ * const keyProvider = new AleoKeyProvider();
468
+ * keyProvider.useCache = true;
469
+ *
470
+ * // Create a new ProgramManager with the key that will be used to unbond credits.
471
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
472
+ * const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
473
+ * console.log(tx);
474
+ *
475
+ * // The transaction can be submitted later to the network using the network client.
476
+ * programManager.networkClient.submitTransaction(tx);
477
+ */
478
+ buildUnbondPublicTransaction(staker_address: string, amount: number, options?: Partial<ExecuteOptions>): Promise<Transaction>;
479
+ /**
480
+ * Unbond a specified amount of staked credits.
481
+ *
482
+ * @example
483
+ * // Create a keyProvider to handle key management
484
+ * const keyProvider = new AleoKeyProvider();
485
+ * keyProvider.useCache = true;
486
+ *
487
+ * // Create a new ProgramManager with the key that will be used to bond credits
488
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
489
+ * programManager.setAccount(new Account("YourPrivateKey"));
490
+ *
491
+ * // Create the bonding transaction and send it to the network
492
+ * const tx_id = await programManager.unbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 10);
493
+ *
494
+ * @returns string
495
+ * @param {string} staker_address Address of the staker who is unbonding the credits
496
+ * @param {number} amount Amount of credits to unbond. If the address of the executor of this function is an
497
+ * existing validator, it will subtract this amount of credits from the validator's staked credits. If there are
498
+ * less than 1,000,000 credits staked pool after the unbond, the validator will be removed from the validator set.
499
+ * If the address of the executor of this function is not a validator and has credits bonded as a delegator, it will
500
+ * subtract this amount of credits from the delegator's staked credits. If there are less than 10 credits bonded
501
+ * after the unbond operation, the delegator will be removed from the validator's staking pool.
502
+ * @param {ExecuteOptions} options Options for the execution
503
+ */
504
+ unbondPublic(staker_address: string, amount: number, options?: Partial<ExecuteOptions>): Promise<string>;
505
+ /**
506
+ * Build a transaction to claim unbonded public credits in the Aleo network.
507
+ *
508
+ * @param {string} staker_address - The address of the staker who is claiming the credits.
509
+ * @param {Partial<ExecuteOptions>} options - Override default execution options.
510
+ * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.
511
+ *
512
+ * @example
513
+ * // Create a keyProvider to handle key management
514
+ * const keyProvider = new AleoKeyProvider();
515
+ * keyProvider.useCache = true;
516
+ *
517
+ * // Create a new ProgramManager with the key that will be used to claim unbonded credits.
518
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
519
+ *
520
+ * // Create the claim unbonded transaction object for later use.
521
+ * const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
522
+ * console.log(tx);
523
+ *
524
+ * // The transaction can be submitted later to the network using the network client.
525
+ * programManager.networkClient.submitTransaction(tx);
526
+ */
527
+ buildClaimUnbondPublicTransaction(staker_address: string, options?: Partial<ExecuteOptions>): Promise<Transaction>;
528
+ /**
529
+ * Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will
530
+ * claim them and add them to the public balance of the account.
531
+ *
532
+ * @example
533
+ * // Create a keyProvider to handle key management
534
+ * const keyProvider = new AleoKeyProvider();
535
+ * keyProvider.useCache = true;
536
+ *
537
+ * // Create a new ProgramManager with the key that will be used to bond credits
538
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
539
+ * programManager.setAccount(new Account("YourPrivateKey"));
540
+ *
541
+ * // Create the bonding transaction
542
+ * const tx_id = await programManager.claimUnbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
543
+ *
544
+ * @param {string} staker_address Address of the staker who is claiming the credits
545
+ * @param {ExecuteOptions} options
546
+ * @returns string
547
+ */
548
+ claimUnbondPublic(staker_address: string, options?: Partial<ExecuteOptions>): Promise<string>;
549
+ /**
550
+ * Build a set_validator_state transaction for later usage.
551
+ *
552
+ * This function allows a validator to set their state to be either opened or closed to new stakers.
553
+ * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.
554
+ * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.
555
+ *
556
+ * This function serves two primary purposes:
557
+ * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.
558
+ * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
559
+ *
560
+ * @example
561
+ * // Create a keyProvider to handle key management
562
+ * const keyProvider = new AleoKeyProvider();
563
+ * keyProvider.useCache = true;
564
+ *
565
+ * // Create a new ProgramManager with the key that will be used to bond credits
566
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
567
+ * programManager.setAccount(new Account("ValidatorPrivateKey"));
568
+ *
569
+ * // Create the bonding transaction
570
+ * const tx = await programManager.buildSetValidatorStateTransaction(true);
571
+ *
572
+ * // The transaction can be submitted later to the network using the network client.
573
+ * programManager.networkClient.submitTransaction(tx);
574
+ *
575
+ * @returns string
576
+ * @param {boolean} validator_state
577
+ * @param {Partial<ExecuteOptions>} options - Override default execution options
578
+ */
579
+ buildSetValidatorStateTransaction(validator_state: boolean, options?: Partial<ExecuteOptions>): Promise<string>;
580
+ /**
581
+ * Submit a set_validator_state transaction to the Aleo Network.
582
+ *
583
+ * This function allows a validator to set their state to be either opened or closed to new stakers.
584
+ * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.
585
+ * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.
586
+ *
587
+ * This function serves two primary purposes:
588
+ * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.
589
+ * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
590
+ *
591
+ * @example
592
+ * // Create a keyProvider to handle key management
593
+ * const keyProvider = new AleoKeyProvider();
594
+ * keyProvider.useCache = true;
595
+ *
596
+ * // Create a new ProgramManager with the key that will be used to bond credits
597
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
598
+ * programManager.setAccount(new Account("ValidatorPrivateKey"));
599
+ *
600
+ * // Create the bonding transaction
601
+ * const tx_id = await programManager.setValidatorState(true);
602
+ *
603
+ * @returns string
604
+ * @param {boolean} validator_state
605
+ * @param {Partial<ExecuteOptions>} options - Override default execution options
606
+ */
607
+ setValidatorState(validator_state: boolean, options?: Partial<ExecuteOptions>): Promise<string>;
608
+ /**
609
+ * Verify a proof of execution from an offline execution
610
+ *
611
+ * @param {executionResponse} executionResponse
612
+ * @returns {boolean} True if the proof is valid, false otherwise
613
+ */
614
+ verifyExecution(executionResponse: ExecutionResponse): boolean;
615
+ /**
616
+ * Create a program object from a program's source code
617
+ *
618
+ * @param {string} program Program source code
619
+ * @returns {Program} The program object
620
+ */
621
+ createProgramFromSource(program: string): Program;
622
+ /**
623
+ * Get the credits program object
624
+ *
625
+ * @returns {Program} The credits program object
626
+ */
627
+ creditsProgram(): Program;
628
+ /**
629
+ * Verify a program is valid
630
+ *
631
+ * @param {string} program The program source code
632
+ */
633
+ verifyProgram(program: string): boolean;
634
+ getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext>;
635
+ }
636
+ export { ProgramManager };