Skip Navigation

[Solana dev] How to swap SOL <-> token / vise versa but on-chain (in a smart contract)? On Raydium or SolDex

How to swap a token for SOL or vise versa** from within** a Solana smart contract? That is, on-chain. How to interract with a router of either Raydium or SolDex? I haven't found any example of this.

1
1 comments
  • Why are you even interested in SOL?

    They have proven themselves to be CeFi
    (Centralized Finance),
    by pausing the chain at will multiple times..