Skip to content

Commit 031672a

Browse files
clean
1 parent 8ea4848 commit 031672a

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/scripts/compress.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const PAYER_KEYPAIR = Keypair.fromSecretKey(
2828
const mintAddress = MINT_ADDRESS;
2929
const payer = PAYER_KEYPAIR;
3030

31+
const amount = bn(333); // each recipient will receive 111 tokens
32+
const recipients = ["GMPWaPPrCeZPse5kwSR3WUrqYAPrVZBSVwymqh7auNW7"].map(
33+
(address) => new PublicKey(address)
34+
);
3135
const activeStateTrees = await connection.getCachedActiveStateTreeInfo();
3236

3337
/// Pick a new tree for each transaction!
@@ -45,11 +49,7 @@ const PAYER_KEYPAIR = Keypair.fromSecretKey(
4549
// Airdrop to example recipients addresses
4650
// 1 recipient = 120_000 CU
4751
// 5 recipients = 170_000 CU
48-
const airDropAddresses = [
49-
"GMPWaPPrCeZPse5kwSR3WUrqYAPrVZBSVwymqh7auNW7",
50-
].map((address) => new web3.PublicKey(address));
5152

52-
const amount = bn(111); // each recipient will receive 111 tokens
5353
const instructions: web3.TransactionInstruction[] = [];
5454

5555
instructions.push(
@@ -64,8 +64,8 @@ const PAYER_KEYPAIR = Keypair.fromSecretKey(
6464
payer: payer.publicKey,
6565
owner: payer.publicKey,
6666
source: sourceTokenAccount.address, // here, the owner of this account is also the payer.
67-
toAddress: airDropAddresses,
68-
amount: airDropAddresses.map(() => amount),
67+
toAddress: recipients,
68+
amount: recipients.map(() => amount),
6969
mint: mintAddress,
7070
outputStateTree: tree,
7171
});
@@ -74,8 +74,8 @@ const PAYER_KEYPAIR = Keypair.fromSecretKey(
7474
// Use zk-compression LUT for your network
7575
// https://www.zkcompression.com/developers/protocol-addresses-and-urls#lookup-tables
7676
const lookupTableAddress = new web3.PublicKey(
77-
// "9NYFyEqPkyXUhkerbGHXUXkvb4qpzeEdHuGpgbgpH1NJ" // mainnet
78-
"qAJZMgnQJ8G6vA3WRcjD9Jan1wtKkaCFWLWskxJrR5V" // devnet
77+
"9NYFyEqPkyXUhkerbGHXUXkvb4qpzeEdHuGpgbgpH1NJ" // mainnet
78+
// "qAJZMgnQJ8G6vA3WRcjD9Jan1wtKkaCFWLWskxJrR5V" // devnet
7979
);
8080

8181
// Get the lookup table account state
@@ -97,15 +97,9 @@ const PAYER_KEYPAIR = Keypair.fromSecretKey(
9797
[lookupTableAccount]
9898
);
9999

100-
const simulate = await connection.simulateTransaction(tx);
101-
if (simulate.value.err) {
102-
console.error("Simulation failed", simulate);
103-
} else {
104-
console.log("Simulation successful", simulate);
105-
}
106100
// Uncomment to send the transaction.
107-
// const txId = await sendAndConfirmTx(connection, tx);
108-
// console.log(`txId: ${txId}`);
101+
const txId = await sendAndConfirmTx(connection, tx);
102+
console.log(`txId: ${txId}`);
109103
} catch (e) {
110104
console.error(`Compression failed:`, e);
111105
}

src/scripts/transfer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import {
1818
BOB_KEYPAIR,
1919
} from "../constants";
2020
import { BN } from "bn.js";
21-
const payer = BOB_KEYPAIR!;
22-
const tokenRecipient = PAYER_KEYPAIR;
21+
22+
const payer = PAYER_KEYPAIR;
23+
const tokenRecipient = BOB_KEYPAIR!;
2324
console.log(payer.publicKey.toBase58());
2425
console.log(tokenRecipient.publicKey.toBase58());
2526
/// Localnet, expects `light test-validator` to be running:

0 commit comments

Comments
 (0)