I want to implement restricting SOL transfers using an anchor/rust program but cannot find any info on this in their documentation. Is there no option to filter or some kind of event/callback that my on-chain code can connect to? Ethereum has something to facilitate this called "require" as described in https://ethereum.stackexchange.com/questions/41659/how-can-i-decline-a-smart-contract-transaction

Is there anything similar for Solana programs?

  • 1
    Based on what criteria would you like to restrict transfers? The identity of the caller?
    – sohrab
    Commented Sep 26, 2022 at 7:54

1 Answer 1


For a simple transfer, you cannot prevent someone from directly sending sol to your address.

On the other hand, if you want to restrict execution of your program to require a minimum payment, that's easy. Simply transfer the minimum required sol within your instruction. The user does not need to execute any transfers of their own.

In Solana, once someone signs a transaction, they give unrestricted access to all of their account balances to any invoked programs. If they have the balance in their account and they sign the transaction, your program can take what it wants. If they have insufficient balance, the instruction will fail, which blocks any part of the entire transaction from persisting. In other words, no transfer will be executed unless they have the minimum required amount available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.