create-leo-app 0.9.10 → 0.9.12
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.
- package/package.json +3 -1
- package/template-build-and-execute-authorization-ts/README.md +5 -0
- package/template-build-and-execute-authorization-ts/_gitignore +24 -0
- package/template-build-and-execute-authorization-ts/dist/index.js +51 -0
- package/template-build-and-execute-authorization-ts/dist/index.js.map +1 -0
- package/template-build-and-execute-authorization-ts/package.json +19 -0
- package/template-build-and-execute-authorization-ts/rollup.config.js +19 -0
- package/template-build-and-execute-authorization-ts/src/index.ts +64 -0
- package/template-build-and-execute-authorization-ts/tsconfig.json +15 -0
- package/template-extension/package.json +1 -1
- package/template-nextjs-ts/package.json +1 -1
- package/template-node/package.json +1 -1
- package/template-node-ts/dist/index.js +46 -23
- package/template-node-ts/dist/index.js.map +1 -1
- package/template-node-ts/package.json +1 -1
- package/template-node-ts/src/index.ts +1 -1
- package/template-node-ts/tsconfig.json +1 -1
- package/template-offline-public-transaction-ts/package.json +1 -1
- package/template-private-transaction-ts/README.md +17 -0
- package/template-private-transaction-ts/_gitignore +24 -0
- package/template-private-transaction-ts/dist/index.js +39 -0
- package/template-private-transaction-ts/dist/index.js.map +1 -0
- package/template-private-transaction-ts/package.json +19 -0
- package/template-private-transaction-ts/rollup.config.js +19 -0
- package/template-private-transaction-ts/src/index.ts +43 -0
- package/template-private-transaction-ts/tsconfig.json +15 -0
- package/template-react-leo/package.json +1 -1
- package/template-react-managed-worker/package.json +1 -1
- package/template-react-ts/package.json +1 -1
- package/template-vanilla/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-leo-app",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"collaborators": [
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
"template-extension",
|
|
13
13
|
"template-nextjs-ts",
|
|
14
14
|
"template-node-ts",
|
|
15
|
+
"template-build-and-execute-authorization-ts",
|
|
15
16
|
"template-node",
|
|
16
17
|
"template-offline-public-transaction-ts",
|
|
18
|
+
"template-private-transaction-ts",
|
|
17
19
|
"template-react-leo",
|
|
18
20
|
"template-react-managed-worker",
|
|
19
21
|
"template-react-ts",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
dist-ssr
|
|
13
|
+
*.local
|
|
14
|
+
|
|
15
|
+
# Editor directories and files
|
|
16
|
+
.vscode/*
|
|
17
|
+
!.vscode/extensions.json
|
|
18
|
+
.idea
|
|
19
|
+
.DS_Store
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { initThreadPool, AleoKeyProvider, ProgramManager, PrivateKey } from '@provablehq/sdk';
|
|
2
|
+
|
|
3
|
+
await initThreadPool();
|
|
4
|
+
// Create a new KeyProvider.
|
|
5
|
+
const keyProvider = new AleoKeyProvider();
|
|
6
|
+
keyProvider.useCache(true);
|
|
7
|
+
// Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
8
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider);
|
|
9
|
+
// Build the `Authorization`.
|
|
10
|
+
const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
11
|
+
const authorization = await programManager.buildAuthorization({
|
|
12
|
+
programName: "credits.aleo",
|
|
13
|
+
functionName: "transfer_public",
|
|
14
|
+
privateKey,
|
|
15
|
+
inputs: [
|
|
16
|
+
"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
|
|
17
|
+
"10000000u64",
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
console.log("Getting execution id");
|
|
21
|
+
// Derive the execution ID and base fee.
|
|
22
|
+
const executionId = authorization.toExecutionId().toString();
|
|
23
|
+
console.log("Estimating fee");
|
|
24
|
+
// Get the base fee in microcredits.
|
|
25
|
+
const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({
|
|
26
|
+
programName: "credits.aleo",
|
|
27
|
+
authorization,
|
|
28
|
+
});
|
|
29
|
+
const baseFeeCredits = Number(baseFeeMicrocredits) / 1000000;
|
|
30
|
+
console.log("Building fee authorization");
|
|
31
|
+
// Build a credits.aleo/fee_public `Authorization`.
|
|
32
|
+
const feeAuthorization = await programManager.buildFeeAuthorization({
|
|
33
|
+
deploymentOrExecutionId: executionId,
|
|
34
|
+
baseFeeCredits,
|
|
35
|
+
privateKey
|
|
36
|
+
});
|
|
37
|
+
console.log("Executing authorizations");
|
|
38
|
+
// Build and execute the transaction.
|
|
39
|
+
const tx = await programManager.buildTransactionFromAuthorization({
|
|
40
|
+
programName: "credits.aleo",
|
|
41
|
+
authorization,
|
|
42
|
+
feeAuthorization,
|
|
43
|
+
});
|
|
44
|
+
// Submit the transaction to the network.
|
|
45
|
+
await programManager.networkClient.submitTransaction(tx.toString());
|
|
46
|
+
// Verify the transaction was successful.
|
|
47
|
+
setTimeout(async () => {
|
|
48
|
+
const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
49
|
+
console.log(transaction);
|
|
50
|
+
}, 10000);
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-build-and-execute-authorization-ts-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rimraf dist/js && rollup --config",
|
|
8
|
+
"dev": "npm run build && node dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@provablehq/sdk": "^0.9.12"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"rimraf": "^6.0.1",
|
|
15
|
+
"rollup": "^4.32.0",
|
|
16
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
17
|
+
"typescript": "^5.7.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import typescript from "rollup-plugin-typescript2";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
input: {
|
|
5
|
+
index: "./src/index.ts",
|
|
6
|
+
},
|
|
7
|
+
output: {
|
|
8
|
+
dir: `dist`,
|
|
9
|
+
format: "es",
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
},
|
|
12
|
+
external: ['@provablehq/sdk'],
|
|
13
|
+
plugins: [
|
|
14
|
+
typescript({
|
|
15
|
+
tsconfig: "tsconfig.json",
|
|
16
|
+
clean: true,
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AleoKeyProvider, PrivateKey, initThreadPool, ProgramManager } from "@provablehq/sdk";
|
|
2
|
+
|
|
3
|
+
await initThreadPool();
|
|
4
|
+
|
|
5
|
+
// Create a new KeyProvider.
|
|
6
|
+
const keyProvider = new AleoKeyProvider();
|
|
7
|
+
keyProvider.useCache(true);
|
|
8
|
+
|
|
9
|
+
// Initialize a program manager with the key provider to automatically fetch keys for executions.
|
|
10
|
+
const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider);
|
|
11
|
+
|
|
12
|
+
// Build the `Authorization`.
|
|
13
|
+
const privateKey = new PrivateKey(); // Change this to a private key that has an aleo credit balance.
|
|
14
|
+
const authorization = await programManager.buildAuthorization({
|
|
15
|
+
programName: "credits.aleo",
|
|
16
|
+
functionName: "transfer_public",
|
|
17
|
+
privateKey,
|
|
18
|
+
inputs: [
|
|
19
|
+
"aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
|
|
20
|
+
"10000000u64",
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log("Getting execution id");
|
|
25
|
+
|
|
26
|
+
// Derive the execution ID and base fee.
|
|
27
|
+
const executionId = authorization.toExecutionId().toString();
|
|
28
|
+
|
|
29
|
+
console.log("Estimating fee");
|
|
30
|
+
|
|
31
|
+
// Get the base fee in microcredits.
|
|
32
|
+
const baseFeeMicrocredits = await programManager.estimateFeeForAuthorization({
|
|
33
|
+
programName: "credits.aleo",
|
|
34
|
+
authorization,
|
|
35
|
+
});
|
|
36
|
+
const baseFeeCredits = Number(baseFeeMicrocredits)/1000000;
|
|
37
|
+
|
|
38
|
+
console.log("Building fee authorization");
|
|
39
|
+
|
|
40
|
+
// Build a credits.aleo/fee_public `Authorization`.
|
|
41
|
+
const feeAuthorization = await programManager.buildFeeAuthorization({
|
|
42
|
+
deploymentOrExecutionId: executionId,
|
|
43
|
+
baseFeeCredits,
|
|
44
|
+
privateKey
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
console.log("Executing authorizations");
|
|
48
|
+
|
|
49
|
+
// Build and execute the transaction.
|
|
50
|
+
const tx = await programManager.buildTransactionFromAuthorization({
|
|
51
|
+
programName: "credits.aleo",
|
|
52
|
+
authorization,
|
|
53
|
+
feeAuthorization,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Submit the transaction to the network.
|
|
57
|
+
await programManager.networkClient.submitTransaction(tx.toString());
|
|
58
|
+
|
|
59
|
+
// Verify the transaction was successful.
|
|
60
|
+
setTimeout(async () => {
|
|
61
|
+
const transaction = await programManager.networkClient.getTransaction(tx.id());
|
|
62
|
+
console.log(transaction);
|
|
63
|
+
}, 10000);
|
|
64
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
"target": "es2017",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
|
|
7
|
+
/* Module Resolution Options */
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
|
|
11
|
+
/* Advanced Options */
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,26 +1,49 @@
|
|
|
1
|
-
import { initThreadPool, ProgramManager, Account, AleoKeyProvider } from '@provablehq/sdk';
|
|
1
|
+
import { initThreadPool, ProgramManager, Account, AleoKeyProvider, AleoKeyProviderParams } from '@provablehq/sdk';
|
|
2
2
|
|
|
3
3
|
await initThreadPool();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
await programManager.
|
|
25
|
-
|
|
4
|
+
const programName = "hello_hello.aleo";
|
|
5
|
+
const hello_hello_program = `
|
|
6
|
+
program ${programName};
|
|
7
|
+
|
|
8
|
+
function hello:
|
|
9
|
+
input r0 as u32.public;
|
|
10
|
+
input r1 as u32.private;
|
|
11
|
+
add r0 r1 into r2;
|
|
12
|
+
output r2 as u32.private;`;
|
|
13
|
+
async function localProgramExecution(program, programName, aleoFunction, inputs) {
|
|
14
|
+
const programManager = new ProgramManager();
|
|
15
|
+
// Create a temporary account for the execution of the program
|
|
16
|
+
const account = new Account();
|
|
17
|
+
programManager.setAccount(account);
|
|
18
|
+
// Create a key provider in order to re-use the same key for each execution
|
|
19
|
+
const keyProvider = new AleoKeyProvider();
|
|
20
|
+
keyProvider.useCache(true);
|
|
21
|
+
programManager.setKeyProvider(keyProvider);
|
|
22
|
+
// Pre-synthesize the program keys and then cache them in memory using key provider
|
|
23
|
+
try {
|
|
24
|
+
const keyPair = await programManager.synthesizeKeys(hello_hello_program, aleoFunction, inputs);
|
|
25
|
+
programManager.keyProvider.cacheKeys(`${programName}:${aleoFunction}`, keyPair);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new Error(`Failed to synthesize keys: ${e.message}`);
|
|
29
|
+
}
|
|
30
|
+
// Specify parameters for the key provider to use search for program keys. In particular specify the cache key
|
|
31
|
+
// that was used to cache the keys in the previous step.
|
|
32
|
+
const keyProviderParams = new AleoKeyProviderParams({ cacheKey: `${programName}:${aleoFunction}` });
|
|
33
|
+
// Execute once using the key provider params defined above. This will use the cached proving keys and make
|
|
34
|
+
// execution significantly faster.
|
|
35
|
+
let executionResponse = await programManager.run(program, aleoFunction, inputs, true, undefined, keyProviderParams);
|
|
36
|
+
console.log("hello_hello/hello executed - result:", executionResponse.getOutputs());
|
|
37
|
+
// Verify the execution using the verifying key that was generated earlier.
|
|
38
|
+
if (programManager.verifyExecution(executionResponse, 9000000)) {
|
|
39
|
+
console.log("hello_hello/hello execution verified!");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw ("Execution failed verification!");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const start = Date.now();
|
|
46
|
+
console.log("Starting execute!");
|
|
47
|
+
await localProgramExecution(hello_hello_program, programName, "hello", ["5u32", "5u32"]);
|
|
48
|
+
console.log("Execute finished!", Date.now() - start);
|
|
26
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Node.js Private Transfer Example
|
|
2
|
+
|
|
3
|
+
This example shows how to build a transfer_private transaction using the ProgramManager.
|
|
4
|
+
|
|
5
|
+
This example can be run with the following
|
|
6
|
+
|
|
7
|
+
#### Yarn
|
|
8
|
+
```bash
|
|
9
|
+
yarn dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
#### NPM
|
|
13
|
+
```bash
|
|
14
|
+
npm run dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Recommend Node.js 20+ for best performance.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
dist-ssr
|
|
13
|
+
*.local
|
|
14
|
+
|
|
15
|
+
# Editor directories and files
|
|
16
|
+
.vscode/*
|
|
17
|
+
!.vscode/extensions.json
|
|
18
|
+
.idea
|
|
19
|
+
.DS_Store
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { initThreadPool, Account, ProgramManager, AleoKeyProvider } from '@provablehq/sdk/testnet.js';
|
|
2
|
+
import { CREDITS_PROGRAM_KEYS } from '@provablehq/sdk/mainnet.js';
|
|
3
|
+
|
|
4
|
+
// Initialize the threadpool to speed up proving.
|
|
5
|
+
await initThreadPool();
|
|
6
|
+
// Specify the record to send.
|
|
7
|
+
const sendRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 500000u64.private,\n _nonce: 2128807984625485873765840993868794284062894954530194503954279385341936659546group.public,\n _version: 1u8.public\n}";
|
|
8
|
+
// Specify the fee record to use for the transaction.
|
|
9
|
+
const feeRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 50000u64.private,\n _nonce: 8327477210335641151082470829879168522735279120730137538049818239556464339772group.public,\n _version: 1u8.public\n}";
|
|
10
|
+
// Import the account.
|
|
11
|
+
const accountCiphertext = "ciphertext1qvq283j7ujnhz59d4rnu772rfmvf94039x9ekhk2lzuutteqzlghsr3g9824qgw97a79mmdymqdt0ulqdkahq39vnerw2tl7thvvnnunq386jzjnw29e0ghnq7unphgdzw637q3fgvvlkrcywsc5jukkdhss5qq3njp";
|
|
12
|
+
const account = Account.fromCiphertext(accountCiphertext, "provablealeo1");
|
|
13
|
+
// Specify the recipient.
|
|
14
|
+
const recipient = "aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3";
|
|
15
|
+
// Create a program manager with the account desired.
|
|
16
|
+
const programManager = new ProgramManager();
|
|
17
|
+
programManager.setAccount(account);
|
|
18
|
+
// Create a key provider in order to re-use the same key for each execution
|
|
19
|
+
const keyProvider = new AleoKeyProvider();
|
|
20
|
+
keyProvider.useCache(true);
|
|
21
|
+
// Initialize the keyProvider cache with all necessary keys.
|
|
22
|
+
await Promise.all([keyProvider.transferKeys("private"), keyProvider.feePrivateKeys()]);
|
|
23
|
+
programManager.setKeyProvider(keyProvider);
|
|
24
|
+
programManager.setInclusionProver();
|
|
25
|
+
const start = Date.now();
|
|
26
|
+
console.log("Starting transfer_private execution");
|
|
27
|
+
// Construct the transfer_private transaction.
|
|
28
|
+
const transfer_private_tx = await programManager.buildExecutionTransaction({
|
|
29
|
+
programName: "credits.aleo",
|
|
30
|
+
functionName: "transfer_private",
|
|
31
|
+
priorityFee: 0,
|
|
32
|
+
privateFee: true,
|
|
33
|
+
inputs: [sendRecord, recipient, "500000u64"],
|
|
34
|
+
feeRecord,
|
|
35
|
+
keySearchParams: { "cacheKey": CREDITS_PROGRAM_KEYS.getKey("transfer_private").locator }
|
|
36
|
+
});
|
|
37
|
+
console.log(`transfer_private Execute finished in ${Date.now() - start}ms`);
|
|
38
|
+
console.log(`Private execution ${transfer_private_tx}`);
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-ts-transfer-private-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rimraf dist/js && rollup --config",
|
|
8
|
+
"dev": "npm run build && node dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@provablehq/sdk": "^0.9.12"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"rimraf": "^6.0.1",
|
|
15
|
+
"rollup": "^4.32.0",
|
|
16
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
17
|
+
"typescript": "^5.7.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import typescript from "rollup-plugin-typescript2";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
input: {
|
|
5
|
+
index: "./src/index.ts",
|
|
6
|
+
},
|
|
7
|
+
output: {
|
|
8
|
+
dir: `dist`,
|
|
9
|
+
format: "es",
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
},
|
|
12
|
+
external: ['@provablehq/sdk'],
|
|
13
|
+
plugins: [
|
|
14
|
+
typescript({
|
|
15
|
+
tsconfig: "tsconfig.json",
|
|
16
|
+
clean: true,
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {Account, initThreadPool, ProgramManager, AleoKeyProvider} from "@provablehq/sdk/testnet.js";
|
|
2
|
+
import { CREDITS_PROGRAM_KEYS } from "@provablehq/sdk/mainnet.js";
|
|
3
|
+
|
|
4
|
+
// Initialize the threadpool to speed up proving.
|
|
5
|
+
await initThreadPool();
|
|
6
|
+
|
|
7
|
+
// Specify the record to send.
|
|
8
|
+
const sendRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 500000u64.private,\n _nonce: 2128807984625485873765840993868794284062894954530194503954279385341936659546group.public,\n _version: 1u8.public\n}";
|
|
9
|
+
// Specify the fee record to use for the transaction.
|
|
10
|
+
const feeRecord = "{\n owner: aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3.private,\n microcredits: 50000u64.private,\n _nonce: 8327477210335641151082470829879168522735279120730137538049818239556464339772group.public,\n _version: 1u8.public\n}";
|
|
11
|
+
// Import the account.
|
|
12
|
+
const accountCiphertext = "ciphertext1qvq283j7ujnhz59d4rnu772rfmvf94039x9ekhk2lzuutteqzlghsr3g9824qgw97a79mmdymqdt0ulqdkahq39vnerw2tl7thvvnnunq386jzjnw29e0ghnq7unphgdzw637q3fgvvlkrcywsc5jukkdhss5qq3njp";
|
|
13
|
+
const account = Account.fromCiphertext(accountCiphertext, "provablealeo1");
|
|
14
|
+
// Specify the recipient.
|
|
15
|
+
const recipient = "aleo1vskzxa2qqgnhznxsqh6tgq93c30sfkj6xqwe7sr85lgjkexjlcxs3lxhy3";
|
|
16
|
+
|
|
17
|
+
// Create a program manager with the account desired.
|
|
18
|
+
const programManager = new ProgramManager();
|
|
19
|
+
programManager.setAccount(account);
|
|
20
|
+
|
|
21
|
+
// Create a key provider in order to re-use the same key for each execution
|
|
22
|
+
const keyProvider = new AleoKeyProvider();
|
|
23
|
+
keyProvider.useCache(true);
|
|
24
|
+
|
|
25
|
+
// Initialize the keyProvider cache with all necessary keys.
|
|
26
|
+
await Promise.all([keyProvider.transferKeys("private"), keyProvider.feePrivateKeys()]);
|
|
27
|
+
programManager.setKeyProvider(keyProvider);
|
|
28
|
+
programManager.setInclusionProver();
|
|
29
|
+
|
|
30
|
+
const start = Date.now();
|
|
31
|
+
console.log("Starting transfer_private execution");
|
|
32
|
+
// Construct the transfer_private transaction.
|
|
33
|
+
const transfer_private_tx = await programManager.buildExecutionTransaction({
|
|
34
|
+
programName: "credits.aleo",
|
|
35
|
+
functionName: "transfer_private",
|
|
36
|
+
priorityFee: 0,
|
|
37
|
+
privateFee: true,
|
|
38
|
+
inputs: [sendRecord, recipient, "500000u64"],
|
|
39
|
+
feeRecord,
|
|
40
|
+
keySearchParams: { "cacheKey" : CREDITS_PROGRAM_KEYS.getKey("transfer_private").locator}
|
|
41
|
+
});
|
|
42
|
+
console.log(`transfer_private Execute finished in ${Date.now() - start}ms`);
|
|
43
|
+
console.log(`Private execution ${transfer_private_tx}`);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
"target": "es2017",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
|
|
7
|
+
/* Module Resolution Options */
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
|
|
11
|
+
/* Advanced Options */
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true
|
|
14
|
+
}
|
|
15
|
+
}
|