Skip to main content

Questions tagged [cpi]

Questions using Cross-Program Invocation (CPI) to make calls between on-chain programs

Filter by
Sorted by
Tagged with
3 votes
1 answer
65 views

Anchor CPI invalid program argument

I want to transfer some lamports (100) froma a PDA to an account. This is the Rust code: pub fn test(ctx: Context<ApproveEscrow>) -> Result<()> { // PDA already initilized in ...
Francesco's user avatar
1 vote
1 answer
19 views

How to use spl_token account with solana-program-test crate?

I am trying to write a test with the solana-program-test crate for a solana program. This program makes a CPI to a token program: let ix = Instruction { program_id: *token_program.key, ...
S.Rivas's user avatar
  • 11
0 votes
1 answer
18 views

Mutate account data of a program by another program

I have a sender program, and a receiver program. What I want to do is, sender program has a account, data_account. I want sender program to call modify_data of receiver program, which in turn mutates ...
woodland's user avatar
0 votes
1 answer
48 views

Get a Solana TX to trigger another TX on chain, and wait for that to complete before proceeding to next instruction/step

i know it is possible, but not exactly sure the best implementation currently, whether to use CPI or not, to have a solana tx, execute on chain and have 1 instruction in there effectively execute ...
Bobby Lee's user avatar
0 votes
0 answers
51 views

Panic on Solana cross program invocation

Program log: panicked at 'range end index 64 out of range for slice of length 0', src/token.rs:551:38, failed: SBF program panicked Where can I investigate 551:38 line of code, or any help on ...
CaminoDS's user avatar
0 votes
1 answer
25 views

Tx Reverting Even If Internal CPI Fails

Creating a CPI call, since it returns a Result. If the internal call throws an error, err should have an err() field as per the definition. The whole transaction should not revert, but it is reverting....
Priyanshu Mishra's user avatar
0 votes
1 answer
24 views

Error: memory allocation failed, out of memory [CPI vs invoke_signed]

When I am creating CPI using the anchor CPI feature, I do not encounter a memory allocation failure. However, when using program::invoke_signed, I do encounter this issue. let mut ireceive_ctx = ...
Priyanshu Mishra's user avatar
3 votes
1 answer
50 views

CpiContext with_remaining_accounts is not working because of lifetimes

I'm writing a Solana program with Anchor 0.29.0 and Solana 1.18.9. I want to invoke through CPI another program. It all worked well until I realised that, the called program needs the remaining ...
dangow3tech's user avatar
0 votes
1 answer
119 views

how to pass `remaining_accounts` from my program to closed-source third-party program?

From on-chain program, calling a normal third-party program (without source code, but has IDL) instruction would be like this: let accounts_meta = vec![ // ... ]; ...
breeze wang's user avatar
1 vote
1 answer
142 views

CPI "Unknown program 11111111111111111111111111111111" error

yo im experiementing with CPI calls on devnet (running test validator locally), and I get this "Unknown program 11111111111111111111111111111111" error with An account required by the ...
4cAsrSgN9r's user avatar
0 votes
1 answer
28 views

Error processing Instruction 2: Cross-program invocation with unauthorized signer or writable account

I am trying to transfer tokens in a PDA and withdraw from that program, deposit works fine but it throws the error when I withdraw. pub fn withdraw_token( ctx: Context<TokenPaymentAccounts&...
user9345's user avatar
1 vote
1 answer
155 views

how to swap between spl tokens inside rust anchor program

I'm going to implement spl token swap with rust inside Anchor project. Basically it's about compounding logic in staking project, so I have to swap reward tokens into stake token and add it to staking ...
cablespecific's user avatar
1 vote
2 answers
36 views

Does a CPI method to a program leave any special footprint on the blockchain?

Firstly, do I understand correctly that CPI call is one of the ways to call a method of program? If so, only by examining a TX on the blockchain, will it be possible to distinguish a CPI call to a ...
kriss100's user avatar
0 votes
0 answers
10 views

Need advice on coding config program and read from it

I want to put configuration into a separate program, and read it from my business program. There are two approach I can think out. Approach 1): const ADMIN_PUBKEY: Pubkey = pubkey!("...
breeze wang's user avatar
0 votes
1 answer
29 views

Do I have to pass in the exact same program account to the program if I want to do CPI with the program account?

I'm developing a on-chain Solana program with Anchor. Let's call this Program A. Inside an instruction of Program A, it'll perform a CPI to invoke Program B. I want to pass Program A as an account ...
Yan's user avatar
  • 375
1 vote
1 answer
50 views

Compute Budget Program Behavior: Direct Call vs. CPI Call and Missing Fees Issue

I've been experimenting with the Compute Budget program to manage transaction costs and noticed something odd. When I invoke Compute Budget directly, everything works as expected. However, invoking it ...
GLG's user avatar
  • 11
1 vote
1 answer
21 views

Having only ProgramB's IDL, expect to call ProgramB from ProgramA using data crafted on client JS, how to make it?

I got a thirty program which only IDL and programID are available. Let call it HelloWorld program. If we call HelloWorld directly, it is simple, just as : const idl = require(<PATH_TO_IDL>); ...
breeze wang's user avatar
0 votes
0 answers
16 views

The deposit was processed with Solana Coin without exchanging honey tokens, so the deposit has not been made yet

At the phantom I didn't exchange honey tokens for solana tokens but deposited them into my solana virtual account It hasn't been deposited into my Solana coin wallet yet Help me
mih's user avatar
  • 1
0 votes
1 answer
31 views

Solana Token Extensions to Modify Transaction

Regarding token extensions: https://cdn.builder.io/o/assets%2Fce0c7323a97a4d91bd0baa7490ec9139%2F83c26b9268f64400b8eb67442579a31a?alt=media&token=525415b0-d3ea-48d7-83d6-0fb0d9e522c6 "...
Drew R's user avatar
  • 21
0 votes
1 answer
61 views

Will inner instructions always contain them all?

I'm basically trying to work out if there's any limit to inner instructions that would limit how much I can rely on them for understanding a transaction. I understand from the docs that a list of them ...
Callum M's user avatar
  • 3,060
0 votes
1 answer
115 views

How to verify secp256k1 signature inside app/business instruction?

I only find one document: secp256k1_instruction. It create two instructions, first one is to call secp256k1_program to verify, second one check the result of first instruction. But this way isn't what ...
breeze wang's user avatar
3 votes
1 answer
367 views

`ProgramFailedToComplete` when I make a transaction

I receive ProgramFailedToComplete when I make a CPI: 1) vault Is initialized!: Error: Raw transaction 3pa2qbGAFNMUbdCXr8nqN43qw9tTzt2ZyFYV3jBAAKN5VpKnOMMMWY4q¿duaUPsUsdtDKsEsgRBLNUGCyk7rFXzb failed ({&...
jakerumbles's user avatar
1 vote
1 answer
73 views

CPI fails with "Cross-program invocation with unauthorized signer or writable account"

Hi I'm having this problem, I'm trying to execute the BuySingleListing from Tensor but by passing the instruction data to my program. The tx works when I just sign it in the frontend, here's the Tx ...
Jhintux's user avatar
  • 11
3 votes
1 answer
85 views

Is there a max number of CPI calls allowed in a single ix / or a transaction as a whole? Or is it unlimited?

Note: I'm not asking about the max depth which is 4. If it is truly unlimited, can we theoretically have as many CPI calls as we want considering we remain under the compute limit?
Syed Ahkam's user avatar
2 votes
3 answers
243 views

Anchor Program unable to sign a transfer with a PDA

I am working on an Anchor Solana program, and I've encountered an error that I'm having trouble resolving. The error is: "Cross-program invocation with unauthorized signer or writable account.&...
Gregz's user avatar
  • 23
0 votes
0 answers
151 views

Trying to do a DEX CPI to perform fully on-chain swaps

I want to create a fully-onchain swap through any clmm dex so for this example I'm trying through raydium even tho I just want to make it work. I'm using the github repo here to import necessary ...
David's user avatar
  • 1
2 votes
2 answers
127 views

failed: Instruction passed to inner instruction is too large (2322 > 1280): CPI call

I understand I need to use a versioned tx with lookup tables to reduce the instruction size but how do I do that with a CPI call? let accounts: Vec<AccountMeta> = ctx ....
Kurtis Streutker's user avatar
1 vote
1 answer
117 views

`Invalid authority type` when trying to Lock an NFT I own via CPIBuilders on anchor

I am trying to call this instruction to lock an NFT. LockCpiBuilder::new(&ctx.accounts.metadata_program) .authority(&ctx.accounts.admin.to_account_info()) //authority ...
Jimii's user avatar
  • 3,160
0 votes
1 answer
39 views

Invoke Signed Mint To Instruction

if let Err(error) = invoke_signed( &SPLIX::mint_to_checked( token_program_account.key, contribution_mint_account.key, contribution_token_account.key, ...
Muhammad Ali's user avatar
1 vote
1 answer
693 views

Raydium swap vs CPI Call to Raydium Program

what is the difference between sending a transaction from a client to the Raydium program to make a swap and making your program that does a cpi call to the Raydium program and sending the transaction ...
kc.sol's user avatar
  • 13
1 vote
0 answers
84 views

How to generate Anchor CPI from source code?

There are a few libraries to gen the Anchor CPI from IDL file, like anchor-gen. They work to some extend, though the output contains some errors that have to be manually fixed. If I have access to the ...
Kise's user avatar
  • 165
0 votes
1 answer
416 views

Provided seeds do not result in a valid address

Here is my initialize instruction: pub fn initialize( ctx: Context<Initialize>, token_name: String, token_symbol: String, token_uri: String, ) -> Result<()> { // PDA ...
Yarik Bratashchuk's user avatar
2 votes
2 answers
693 views

Sign CPI as both a PDA and signer of TX

I am writing an anchor program where I want to sign a CPI as both a PDA from my program and the signer of the tx. I expect it would look something like this: CpiContext::new_with_signer( program, ...
larry 8's user avatar
  • 43
1 vote
1 answer
405 views

Is it possible to set up a Raydium LP from on chain using CPI?

i would like my on-chain program to set up a LP for tokens using Raydium (though happy to use something else), but I can't find any reference/docs on whether this is possible. Does anyone know if this ...
daoplays's user avatar
  • 587
1 vote
0 answers
131 views

Unable to do the CPI to Orca whirlpool program after obtaining its interface via solang

Description We are unable to correctly finalize the call to the Orca whirlpool program fork after we have obtained the whirlpool interface via the solang idl whirlpool.json command. When doing the CPI,...
Aleksandr Kuperman's user avatar
1 vote
0 answers
53 views

how to build data field in the solana instruction manually?

let inst = Instruction::new_with_borsh( ctx.accounts.dest_pm.key(), &data, account_metas, ); invoke(&inst, &vec![ctx.accounts.user....
Aravind Makam's user avatar
0 votes
1 answer
37 views

How to know which program has done CPI for our program?

Suppose, If we have a Program-A which can be called by other programs and users. If a program does a CPI to Program-A, How to know which program is trying to call our program(Program-A).
Aravind Makam's user avatar
0 votes
0 answers
89 views

nft delegate confusion (metaplex token metadata)

I'm trying to delegate an pnft to a pda. but I keep getting incorrect account owner. I can't for the life of me know how the account owner is incorrect. and what the delegate field in the ...
Fares_Hassen's user avatar
2 votes
1 answer
43 views

What are the fees for making CPI calls

Am I correct in assuming that the fees are forever 0.000005 unless factors such as local fee markets come into play?
Jimii's user avatar
  • 3,160
1 vote
1 answer
45 views

having trouble to encode a u64 as data for CPI

I have a u64 which is an amount of lamports. I need to send it to another program with a CPI. So i'm trying to encode it in the data, but can't figure out how to do it. Here is what i tried: let mut ...
Effe2's user avatar
  • 1,178
0 votes
0 answers
51 views

anchor's instruction create account but with CPI?

i have created an anchor method that needs an escrow account. When i use this method, the escrow account is created with instructions: [ await program.account.escrowAccount.createInstruction(escrow), ]...
Effe2's user avatar
  • 1,178
2 votes
0 answers
39 views

A peculiar problem with CPIs

So I'm working on a DAO program and I ran into this really weird error. My program is bespoke, so I'm going to demonstrate the problem with an easier-to-understand program: coral-xyz/multisig. The ...
Proph3t's user avatar
  • 412
2 votes
1 answer
268 views

How are CPI calls charged?

When making CPI calls in my program, I am wondering whether I pay for the transaction cost associated with it. To my understanding my program execution is paused and it goes to executing the cpi-ed ...
Jimii's user avatar
  • 3,160
1 vote
1 answer
133 views

Cannot perform a CPI call using anchor

I tried to make a CPI call from puppret_master to puppet program exactly like the anchor document and i did everything right but "program" AND "cpi" keywords are still unkown for ...
pooria sarkhan's user avatar
1 vote
1 answer
81 views

What is the cost of increasing the CU above 200k

I am making some heavy CPI calls and have increased the compute unit above 200k. Looking at the explorer I did not see any considerable change in how much it costs to do this. Is there a table or how ...
Jimii's user avatar
  • 3,160
0 votes
2 answers
218 views

IdlError: Type not found for custom struct

I got started with writing smart contracts 2 days ago so please bear with me. The function emit_event emits an event. I want to call the function via a CPI form another program. I have written code ...
Wilfred Almeida's user avatar
2 votes
1 answer
109 views

Handling out of memory issues in heap

We have a CPI that uses ~4000 bytes of heap, and it executes a few times in a loop, so for a few executes the program will fail with memory allocation failed, out of memory. The solution has been to ...
Whiteseal's user avatar
  • 3,165
0 votes
1 answer
165 views

How to CPI into token_metadata_program with optional accounts

I am aiming to Cross Program Invoke the transfer method of token_metadata_program. The method takes optional parameters: ... #[account(6, optional, name="edition", desc="Edition of ...
Daniel Pavel's user avatar
1 vote
0 answers
445 views

memory allocation failed, out of memory. SBF program panicked

I have a program that makes ~20 cross program invocations (CPIs). On one CPI it fails when calling process_instruction, stating it ran out of memory. Logs below Program log: Error: memory ...
tomjohn's user avatar
  • 111
2 votes
1 answer
512 views

How to transfer SPL tokens via CPI in Anchor

I'm trying to transfer SPL tokens from a PDA to an user account via CPI but I'm facing "instruction spent from the balance of an account it does not own" error. The PDA is initialized via ...
0xMukesh's user avatar
  • 273