skynetcap / solanaj

Solana RPC client written in Java
MIT License
94 stars 50 forks source link

metaplex candy machine mintV2 Java implementation of Umi mintV2 #66

Open solpower opened 4 weeks ago

solpower commented 4 weeks ago

mint is not success, sendTransaction and response the signature , But the blockchain browser does not have this transaction Where should I troubleshoot the problem? Can give some help?

{"jsonrpc":"2.0","result":"5NkPinTA2mYDnXNAdSXpRZypkzHWHDAfpKP154QruzxDAuPvWRkXz1CioXwNmatfmSuA2ViBeQpADNdfyPLv96LQ","id":"f67457cd-f4fb-4b70-bc7d-f5097d0e3222"}

solpower commented 4 weeks ago

Is there any problem with the following code? Use Umi Sdk to pass the following parameters, there is no problem

public static void mintV2() throws Exception { PublicKey programId = new PublicKey("CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR"); //

    List<AccountMeta> accounts = getAccount();
    byte[] datas = getTransData(); // System.out.println(b & 0x0FF);

    Transaction trans = new Transaction();
    trans.addInstruction(computeUnitPrice()); 
    trans.addInstruction(computeUnitLimit()); 
    trans.addInstruction(new TransactionInstruction(programId, accounts, datas));
    Account signer = new Account(Base58.decode(secret_key));

    List<Account> signers = Arrays.asList(signer, nftMint);
    String signature = client.getApi().sendTransaction(trans, signers, null);
    System.out.println(signature);

}

public static List getAccount() throws Exception { PublicKey nft_mint = nftMint(); PublicKey nft_metadata = nft_metadata(nft_mint); PublicKey nft_master_edition = nft_master_edition(nft_mint); PublicKey associated_token = associatedToken(payer, nft_mint); // 1. 构建所需的账户列表 (Meta, CandyMachine, Mint, Collection, ThirdPartySigner, etc.) List ac = new ArrayList<>(); ac.add(new AccountMeta(new PublicKey("6uMXvQgiZjuk9q5z89dFuLFSJucrkqMwRef2ybPzshac"), false, true));//1 Candy Machine ac.add(new AccountMeta(new PublicKey("9RNrXs4Uin3Cf2TiLb5DFmb3owsHpKMxsv5yZMBSF2w"), false, true));//2 Authority Pda ac.add(new AccountMeta(new PublicKey("EM8kLQLvJonx6JDytaokcEFG7W7owGwD3f4tL5DGfEii"), true, false));//3 Mint Authority ac.add(new AccountMeta(payer, true, true));//4 payer ac.add(new AccountMeta(destination, false, false));//5 nft Owner ac.add(new AccountMeta(nft_mint, true, true));//6 nft_mint ac.add(new AccountMeta(payer, true, false));//7 nft_mint_authority ac.add(new AccountMeta(nft_metadata, false, true));//8 nft_metadata ac.add(new AccountMeta(nft_master_edition, false, true));//9 nft_master_edition ac.add(new AccountMeta(associated_token, false, true));//10 token (optional) ac.add(new AccountMeta(new PublicKey("CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR"), false, false));//11 token_record (optional) ac.add(new AccountMeta(new PublicKey("HkhHa8Ms24LwUUN1iMXQ9Csg5ytSPUray8wvByfN7qop"), false, false));//12 collection_delegate_record ac.add(new AccountMeta(new PublicKey("4inmHPKPxyY1gutvcxbKrcueNuU6gZFqvsSou1q7kTuk"), false, false));//13 collection_mint ac.add(new AccountMeta(new PublicKey("2d5kBbejKbTtPHL73dumhrmg3r2pepiwgc3p5ht45Q7o"), false, true));// 14 collection_metadata ac.add(new AccountMeta(new PublicKey("EMg3BQ33obSXabxEgPtjB4KvTGR6hy6h7X2C3EU2kwhd"), false, false));//15 collection_master_edition ac.add(new AccountMeta(new PublicKey("EM8kLQLvJonx6JDytaokcEFG7W7owGwD3f4tL5DGfEii"), false, false));//16 collection_update_authority ac.add(new AccountMeta(new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), false, false));//17 token_metadata_program ac.add(new AccountMeta(new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), false, false));//18 spl_token_program ac.add(new AccountMeta(new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"), false, false));//19 spl_ata_program (optional) ac.add(new AccountMeta(new PublicKey("11111111111111111111111111111111"), false, false));//20 system_program ac.add(new AccountMeta(new PublicKey("Sysvar1nstructions1111111111111111111111111"), false, false));//21 sysvar_instructions ac.add(new AccountMeta(new PublicKey("SysvarS1otHashes111111111111111111111111111"), false, false));//22 recent_slothashes ac.add(new AccountMeta(new PublicKey("CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR"), false, false));//23 authorization_rules_program (optional) ac.add(new AccountMeta(new PublicKey("CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR"), false, false));//24 authorization_rules (optional) return ac; }

public static byte[] getTransData() throws Exception { ByteBuffer buffer = ByteBuffer.allocate(8); // 8 buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.put((byte)120); buffer.put((byte)121); buffer.put((byte)23); buffer.put((byte)146); buffer.put((byte)173); buffer.put((byte)110); buffer.put((byte)199); buffer.put((byte)205); return buffer.array(); }

public static PublicKey nftMint() throws RpcException {
    Account newAccount = new Account();
    nftMint = newAccount;
    log.info("new mint account: " + newAccount.getPublicKey().toBase58());
    return newAccount.getPublicKey();
}