mhunt_ticket_store/tests/init.ts

37 lines
1.4 KiB
TypeScript

import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { clusterApiUrl, Connection, Keypair, LAMPORTS_PER_SOL, PublicKey, SystemProgram } from "@solana/web3.js";
import { TicketStore } from "../target/types/ticket_store";
import { createMint, createAccount, getAccount, TOKEN_PROGRAM_ID, mintTo, getMint } from "@solana/spl-token";
const mintPubkey = new PublicKey("tktUDLZhFGb9VW9zDxZ7HYDFuBooEf8daZEvPbBY7at");
const programId = new PublicKey("5kgwVNdKDndFYNkUhZ5TvkNXxEJngMSczfS61qNALhzJ");
const signer = Keypair.fromSecretKey(Uint8Array.from([202,150,67,41,155,133,176,172,9,100,150,190,239,37,69,73,18,16,76,65,164,197,99,134,240,151,112,65,61,122,95,41,9,44,6,237,108,123,86,90,144,27,1,160,101,95,239,35,53,91,195,220,22,214,2,84,132,37,20,236,133,242,104,197]));
const IDL = require('../target/idl/ticket_store.json');
// Call the initialize function
Initialize().then(()=>{
console.log("Init complete");
});
async function Initialize(){
const connection = new Connection(clusterApiUrl("devnet"));
const provider = new anchor.AnchorProvider(connection, new anchor.Wallet(signer));
anchor.setProvider(provider);
const program = new Program<TicketStore>(IDL,provider);
console.log(program.programId);
await program.methods
.initialize()
.accounts({
mint: mintPubkey,
})
.signers([signer])
.rpc();
}