Questions tagged [cpi]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 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
  • 2,797
0 votes
0 answers
14 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
54 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
42 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
31 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
117 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
78 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
75 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
51 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
  • 1,438
0 votes
1 answer
26 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
0 votes
1 answer
227 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
  • 3
1 vote
0 answers
34 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
  • 141
0 votes
1 answer
122 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
1 vote
2 answers
611 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
  • 13
0 votes
0 answers
145 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
  • 497
1 vote
0 answers
66 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
34 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
30 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
59 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
33 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
  • 1,438
1 vote
1 answer
32 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,128
0 votes
0 answers
28 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,128
1 vote
0 answers
32 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
  • 402
2 votes
1 answer
244 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
  • 1,438
0 votes
1 answer
63 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
51 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
  • 1,438
0 votes
1 answer
119 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
65 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
  • 2,562
0 votes
1 answer
109 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
139 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
319 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
2 votes
1 answer
141 views

"Error processing Instruction 0: invalid program argument" while invoking method of other program using cpi

The callee program #[program] pub mod puppet { use super::*; pub fn initialize(_ctx: Context<Initialize>) -> Result<()> { Ok(()) } pub fn set_data(ctx: Context&...
SolDev's user avatar
  • 23
0 votes
2 answers
425 views

Can we use pda as signer and payer to create an account in any solana program

I have asked same kind of question earlier but not got proper answer. As I got an answer in my previous question in which I have to use system owned pda account, I have also tried this but getting ...
Panchal Vedant's user avatar
2 votes
1 answer
122 views

How to create an account in any other program using CPI in which PDA is used as signer and payer

I just want to invoke initialize method of callee program from caller program in which pda account should be signer. Callee Program #[program] mod callee { use super::*; // I want to call ...
Panchal Vedant's user avatar
1 vote
1 answer
91 views

How multiple accounts can sign transaction in PDA CPI

How can multiple accounts can sign transaction along with PDA ? In PDA based CPI in which PDA signs transactions, how can we use multiple accounts as a signers ? I have to create an account in callee ...
Panchal Vedant's user avatar
4 votes
3 answers
414 views

Anchor CPI Bubblegum Burn Error Cause Not Signer

when i try to do cpi to program bubblegum to call burn instruction with anchor. https://github.com/metaplex-foundation/metaplex-program-library/tree/master/bubblegum/program i got an error : "...
Alfian Dwi Nugraha's user avatar
3 votes
1 answer
116 views

how to do basic CPI another program from our program?

I've read solana and anchor's documentation on doing CPI, but still don't really understand. what is the basis that must be understood when doing CPI program? for example I want to call function ...
Alfian Dwi Nugraha's user avatar
0 votes
0 answers
92 views

Cross-program invocation: Signer privilege escalated

Thanks ATON for viewing the problem, I need URGENT help on this if possible. I have created a PDA and used the PDA to freeze an NFT. #[account(init, payer=bidder, seeds = [ bidder.key()....
Piyush Chittara's user avatar
3 votes
1 answer
446 views

When passing signer seeds in a CPI, is bump required?

When passing signer seeds to a CPI like this: let seeds = &[ b"whatever".as_ref(), &ctx.accounts.someacc.key().to_bytes()[..], &[bump] ]; let ...
Whiteseal's user avatar
  • 2,562
2 votes
2 answers
164 views

AccountLoader for a struct from another Program

Say I have an account in Program A, and I know it looks like this: #[account(zero_copy)] pub struct SomeAcc { pub some_num: u32, } Now in my Program B, I copy and paste this struct exactly into ...
Whiteseal's user avatar
  • 2,562
4 votes
2 answers
388 views

Anchor CPI within the same program without passing the program

When calling a CPI that calls another instruction in the same program, you need to pass the program into the program, which is awkward. For example, removing this_program as an account here causes the ...
Whiteseal's user avatar
  • 2,562
0 votes
1 answer
50 views

native invoke_signed create_account pda: writable privilege escalated [closed]

i'm thinking the client can't create my pda state_account since only the program can sign for it, but i must be missing something. my native excerpt: let state_account = next_account_info(...
user3438's user avatar
1 vote
2 answers
192 views

Devnet CPI "unknown program" and "An account required by the instruction is missing"

Testing CPI calls on devnet (e.g. programs both deployed to devnet, anchor.toml set to devnet) yields this error: 'Unknown program Ev6JrN5HqrKwXhoB9jucLdn51yzzDvWmBHkubXWavRio', 'Program <...
Whiteseal's user avatar
  • 2,562
4 votes
2 answers
134 views

How to pass an uninitialized PDA account to a CPI to initialize it without getting AccountNotInitialized error

I have ProgramA and ProgramB. ProgramA initializes an account using InstructionA. When ProgramB uses a CPI to call instructionA I'm getting AccountNotInitialized error. I'm using the following code: ...
cris.sol's user avatar
  • 272
1 vote
2 answers
74 views

CPI from Program A to B via a Rust crate?

so what i want to do is I want to do a CPI call From program B to program A, But I want to this via a rust crate, not from program B. Like this use Crate::create_cpi; fn do_something(ctx ...) -> ...
Abhishek Faliya's user avatar
2 votes
1 answer
175 views

How to initialize a PDA before the CPI call? other wise its giving me AccountOwnedByWrongProgram

I'm trying to do a CPI call to my main program, which is #[derive(Accounts)] pub struct RegisterClient<'info> { #[account(mut)] pub owner: Signer<'info>, #[account(init, payer=...
Abhishek Faliya's user avatar
3 votes
1 answer
126 views

how to get signer for the CPI?

Here's my solana program, use my-rust-crate::do_cpi; pub fn do_something(ctx:Context<DoSomething>) => Result<()>{ do_cpi(ctx); } so this my rust crate is where the CPI happens, ...
Abhishek Faliya's user avatar
3 votes
1 answer
108 views

how can i do a CPI in a rust crate with signer from solana program?

What I want to do is use a rust crate in solana program. and a function of the rust crate will do a CPI to another program. how can I sign that CPI with the signer from the main program. Can i pass ...
Abhishek Faliya's user avatar
1 vote
1 answer
49 views

Nesting instruction calls with different signers

I have an Anchor program where one of the instruction calls another like so: #[program] pub mod dippies_index_protocol { use super::*; pub fn foo( ctx: Context<Foo>, ) -> ...
Dodecahedr0x's user avatar
1 vote
1 answer
494 views

CpiContext::new_with_signer privilege escalation

I've been having this problem for a few weeks now. First, I'm creating a PDA for managing campaigns: pub struct CreateCampaign<'info> { #[account( init, payer = ...
Dinaiscoding's user avatar