Подготовка перед деплоем в mainnet

This commit is contained in:
AidarKC
2026-07-01 12:23:30 +04:00
parent ab4dab34aa
commit 0240db59ee
52 changed files with 1018 additions and 473 deletions
@@ -0,0 +1,68 @@
#!/usr/bin/env node
"use strict";
const path = require("path");
const { Connection, PublicKey, Transaction, sendAndConfirmTransaction } = require("@solana/web3.js");
const {
TOKEN_PROGRAM_ID,
getAssociatedTokenAddressSync,
createAssociatedTokenAccountIdempotentInstruction,
createMintToInstruction,
getMint,
} = require("@solana/spl-token");
const { clusterUrl, loadKeypair, parseEnvConfig, resolveConfigPath } = require("./js_common");
async function main() {
const targetWallet = process.argv[3];
const amountRaw = process.argv[4] || "1";
if (!targetWallet) {
throw new Error("Usage: node 01a_mint_governance_token.js <config.env> <target_wallet> [amount]");
}
const cfg = parseEnvConfig(resolveConfigPath(process.argv[2], "dao.config.env"));
if (!cfg.DAO_GOV_TOKEN_MINT) throw new Error("В конфиге пустой DAO_GOV_TOKEN_MINT");
if (!cfg.DAO_ISSUER_KEYPAIR) throw new Error("В конфиге пустой DAO_ISSUER_KEYPAIR");
const conn = new Connection(clusterUrl(cfg.DAO_CLUSTER || "devnet"), "confirmed");
const issuer = loadKeypair(path.resolve(cfg.DAO_ISSUER_KEYPAIR));
const mint = new PublicKey(cfg.DAO_GOV_TOKEN_MINT);
const target = new PublicKey(targetWallet);
const amount = BigInt(amountRaw);
const mintInfo = await getMint(conn, mint, "confirmed", TOKEN_PROGRAM_ID);
if (mintInfo.decimals !== 0) {
throw new Error(`Ожидался governance mint с decimals=0, а получено ${mintInfo.decimals}`);
}
const ata = getAssociatedTokenAddressSync(mint, target, false, TOKEN_PROGRAM_ID);
const tx = new Transaction().add(
createAssociatedTokenAccountIdempotentInstruction(
issuer.publicKey,
ata,
target,
mint,
TOKEN_PROGRAM_ID
),
createMintToInstruction(
mint,
ata,
issuer.publicKey,
amount,
[],
TOKEN_PROGRAM_ID
)
);
const sig = await sendAndConfirmTransaction(conn, tx, [issuer], { commitment: "confirmed" });
console.log("Mint done.");
console.log("target:", target.toBase58());
console.log("ata:", ata.toBase58());
console.log("amount:", amount.toString());
console.log("signature:", sig);
}
main().catch((e) => {
console.error("MintGovernanceToken error:", e?.message || e);
process.exit(1);
});