Combining Modules and Cross-Program Interactions
Last updated
Last updated
A more advanced aspect is when your Nyvo dApp uses multiple on-chain programs (either multiple Nyvo modules or external programs). Solana allows programs to call each other (CPIs, Cross-Program Invocations) and for transactions to include instructions to different programs. If, for example, you integrate an external Oracle or use Solana’s Token Program directly in some custom flow, be aware of CPUs and signer issues:
Only the outer transaction signer (the user’s wallet) and program-derived addresses can sign actions. A program cannot sign with the user’s key, obviously, and it cannot invoke another program requiring a signature the original transaction didn’t have. Nyvo’s generated programs typically avoid needing the program to sign for anything except PDAs it controls.
When combining modules, ensure that account addresses don’t collide. PDAs from different programs are fine even if seeds overlap, because the program id in the derivation is different. Just pass the correct program id when deriving each PDA.
Nyvo likely uses Anchor or similar which by default prevents one Anchor program from easily invoking another unless explicitly allowed via interfaces or cpi-client. If you aim to extend Nyvo’s logic beyond what’s provided, you might consider writing an additional small program that talks to the Nyvo program (for example, a custom program that auto-creates governance proposals based on some trigger). This is advanced and beyond Nyvo’s scope, but keep in mind Solana’s CPI cost – each cross-invocation has overhead and uses extra compute. Simulate and budget compute accordingly if doing this.
In conclusion, these advanced concepts – PDAs, simulation, fees, and rent – are the underpinnings of Solana that Nyvo automates. As an experienced developer, having this knowledge allows you to use Nyvo more effectively, diagnose any issues that arise, and even push the boundaries of what Nyvo’s modules offer with custom enhancements.