This is a quick proof of concept that proves you can make a CPI call in Solana by using an instruction generated in the client-side.
This may be useful in cases where you want a PDA to sign an instruction but for whatever reason do no want to construction the instruction within the program logic. Such reasons may be:
- You don't have the rust bindings of the program that you intend to call via CPI (quick note that this is dangerous since you probably don't know what the program does)
- It is impossible to create the instruction on-chain e.g. Jupiter instructions that find the best swap route have to be done off-chain (as of right now)
This proof of concept does a token transfer instruction that is created off chain and then is signed by a PDA on-chain to prove that it is possible.
- Clone the repo, and install Solana & Anchor
- Run
yarn
to install the packages - Run
anchor test