@provablehq/sdk 0.7.2 → 0.7.3

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