hyperledger-solang/solang

solana cross program invocation

shivamSspirit opened this issue · 3 comments

how to write cpi invoke and invoke signed in solang

there is no detailed explanation in solang docs for this

is solana terms applied as well on this like call depth of cpi (4)

For CPI, you can refer to this example.

This is one way of found cpi

See here what if

here is a library for system instruction

like this
https://github.com/solana-developers/program-examples/blob/8e873058425091769a468fbf2f8eb1d0bda2e9ec/basics/transfer-sol/solang/solidity/transfer-sol.sol

then we don't need to create seprate interface to make cpi we can directly
make cpi using
this

function transferSolWithCpi(address from, address to, uint64 lamports) public {
// CPI to transfer SOL using "system_instruction" library
SystemInstruction.transfer(from, to, lamports);
}

so the thing is in solang we can make cpi using alternative way as our requirment

@shivamsoni00 I am not clear what exactly your requirements are. You can do all kinds of CPI calls with Solang, that should not be a problem.

There is an example anchor project for this here: https://github.com/solana-developers/program-examples/tree/main/basics/cross-program-invocation/solang