Categories
Solana

I am getting this error below when creating tokens

java.lang.RuntimeException: Failed to create brand tokensrntat com.scripledger.services.SolanaService.lambda$createBrandToken$4(SolanaService.java:191)rntat io.smallrye.context.impl.wrappers.SlowContextualSupplier.get(SlowContextualSupplier.java:21)rntat io.smallrye.mutiny.operators.uni.builders.UniCreateFromItemSupplier.subscribe(UniCreateFromItemSupplier.java:28)rntat io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)rntat io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni.subscribe(UniOnItemTransformToUni.java:25)rntat io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)rntat io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.performInnerSubscription(UniOnItemTransformToUni.java:81)rntat io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:57)rntat io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:43)rntat io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:43)rntat io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:43)rntat io.smallrye.mutiny.operators.uni.builders.UniCreateFromPublisher$PublisherSubscriber.onComplete(UniCreateFromPublisher.java:86)rntat io.smallrye.mutiny.subscription.MultiSubscriberAdapter.onCompletion(MultiSubscriberAdapter.java:37)rntat io.smallrye.mutiny.operators.multi.MultiEmitOnOp$MultiEmitOnProcessor.isDoneOrCancelled(MultiEmitOnOp.java:248)rntat io.smallrye.mutiny.operators.multi.MultiEmitOnOp$MultiEmitOnProcessor.run(MultiEmitOnOp.java:188)rntat io.quarkus.mongodb.impl.Wrappers.lambda$toMulti$2(Wrappers.java:32)rntat io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279)rntat io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:261)rntat io.vertx.core.impl.ContextInternal.lambda$runOnContext$0(ContextInternal.java:59)rntat io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)rntat io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)rntat io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)rntat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)rntat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)rntat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)rntat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)rntat java.base/java.lang.Thread.run(Thread.java:842)rnCaused by: java.lang.RuntimeException: Transaction failedrntat com.scripledger.services.SolanaService.lambda$sendTransaction$7(SolanaService.java:215)rntat io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)rntat io.smallrye.mutiny.helpers.UniCallbackSubscriber.onFailure(UniCallbackSubscriber.java:62)rntat io.smallrye.mutiny.operators.uni.builders.UniCreateFromItemSupplier.subscribe(UniCreateFromItemSupplier.java:31)rntat io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)rntat io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:51)rntat io.smallrye.mutiny.groups.UniSubscribe.with(UniSubscribe.java:110)rntat io.smallrye.mutiny.groups.UniSubscribe.with(UniSubscribe.java:88)rntat com.scripledger.services.SolanaService.sendTransaction(SolanaService.java:211)rntat com.scripledger.services.SolanaService.lambda$createBrandToken$4(SolanaService.java:181)rnt… 26 morernCaused by: java.lang.RuntimeException: Failed to send transactionrntat com.scripledger.services.SolanaService.lambda$sendTransaction$5(SolanaService.java:206)rntat io.smallrye.context.impl.wrappers.SlowContextualSupplier.get(SlowContextualSupplier.java:21)rntat io.smallrye.mutiny.operators.uni.builders.UniCreateFromItemSupplier.subscribe(UniCreateFromItemSupplier.java:28)rnt… 32 morernCaused by: org.p2p.solanaj.rpc.RpcException: Transaction simulation failed: Error processing Instruction 1: custom program error: 0xcrntat org.p2p.solanaj.rpc.RpcClient.call(RpcClient.java:51)rntat org.p2p.solanaj.rpc.RpcApi.sendTransaction(RpcApi.java:51)rntat com.scripledger.services.SolanaService.lambda$sendTransaction$5(SolanaService.java:201)rnt…

public Uni<Uni> createBrandToken(String ownerPublicKeyStr, Long initialSupply) { return Uni.createFrom().item(() -> { try { PublicKey ownerPublicKey = new PublicKey(ownerPublicKeyStr); // Log owner account public key LOGGER.info("Owner account public key: " + ownerPublicKey); Account mintAccount = new Account(); PublicKey mintPublicKey = mintAccount.getPublicKey(); // Log mint account public key LOGGER.info("Mint account public key: " + mintPublicKey.toString()); Transaction transaction = new Transaction(); long lamportsForRentExemption = getMinimumBalanceForRentExemption(); TransactionInstruction createAccountInstruction = SystemProgram.createAccount( ownerPublicKey, mintPublicKey, lamportsForRentExemption, TokenProgram.MINT_LAYOUT_SIZE, TokenProgram.PROGRAM_ID ); byte[] data = ByteBuffer.allocate(9) .order(ByteOrder.LITTLE_ENDIAN) .put((byte) 0) // InitializeMint instruction index for the Token Program .putLong(initialSupply) .array(); AccountMeta mintAccountMeta = new AccountMeta(mintPublicKey, false, true); AccountMeta ownerAccountMeta = new AccountMeta(ownerPublicKey, true, false); TransactionInstruction mintInstruction = new TransactionInstruction( TokenProgram.PROGRAM_ID, Arrays.asList(mintAccountMeta, ownerAccountMeta), data ); transaction.addInstruction(createAccountInstruction); transaction.addInstruction(mintInstruction); // Log details of the transaction instructions LOGGER.info("Transaction instructions added:"); logTransactionInstruction(createAccountInstruction); logTransactionInstruction(mintInstruction); return sendTransaction(transaction, mintAccount) .onItem().transform(signature -> { LOGGER.info("Transaction successful with signature: " + signature); return signature; }) .onFailure().invoke(e -> { LOGGER.error("Transaction failed", e); }); } catch (Exception e) { LOGGER.error("Failed to create brand tokens", e); throw new RuntimeException("Failed to create brand tokens", e); } }); } public Uni sendTransaction(Transaction transaction, Account signer) throws IOException { Account feePayerAccount = new Account(Base58.decode(retrievePrivateKey())); // Load fee payer account List signers = Arrays.asList(feePayerAccount, signer); Uni uni = Uni.createFrom().item(() -> { try { String signature = client.getApi().sendTransaction(transaction, signers); LOGGER.info("Transaction sent with signature: " + signature); return signature; } catch (RpcException e) { LOGGER.error("Failed to send transaction", e); throw new RuntimeException("Failed to send transaction", e); } }); // Force subscription and handle errors uni.subscribe().with( signature -> LOGGER.info("Transaction successful with signature: " + signature), failure -> { LOGGER.error("Transaction failed", failure); throw new RuntimeException("Transaction failed", failure); } ); return uni; } private void logTransactionInstruction(TransactionInstruction instruction) { System.out.println("Instruction program id: " + instruction.getProgramId().toString()); instruction.getKeys().forEach(key -> { System.out.println("AccountMeta public key: " + key.getPublicKey().toString()); System.out.println("Is signer: " + key.isSigner()); System.out.println("Is writable: " + key.isWritable()); }); } private long getMinimumBalanceForRentExemption() { // Implement this method to return the minimum balance required for rent exemption. return 2039280; // Example value, replace with actual calculation } public static class TokenProgram { public static final int MINT_LAYOUT_SIZE = 82; public static final PublicKey PROGRAM_ID = new PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"); } 

submitted by /u/Juangunner
[link] [comments]

Join The SmashBotAI Telegram Community Now! Get trade alerts, smashable token trade ideas, and more!

https://t.me/smashbotcommunity

Start Trading Now:

SmashBotAI Telegram Bot

Claim Your $SMASH Airdrop Now!

Join The SmashBotAI Telegram Community Now! Get trade alerts, smashable token trade ideas, and more! https://t.me/smashbotcommunity

Start Trading Now:
SmashBotAI Telegram Bot

Claim Your $SMASH Airdrop Now!

Categories