How to Restrict Token Transfers to Whitelisted Principals in a Dapp?

Hi everyone,

I am developing a Dapp on ICP where I want to implement a whitelist mechanism for token transfers. The goal is to restrict token transfers so that users can only send tokens to other principals that are whitelisted within the Dapp.

  • What is the best approach to implement this on ICP?

  • Is there a way to do this efficiently without modifying the token standard?

Any guidance, sample code, or best practices would be greatly appreciated!

Thanks in advance.

1 Like
3 Likes

thank you but do you know How can I ensure that even if a user sends tokens to a Principal on the NNS, they will not be able to transfer those tokens to another Principal who is not whitelisted? Specifically, I want to restrict token transfers outside my dApp by enforcing whitelist checks at the ledger level.

1 Like

you can’t unless you wrote the code for the token/ledger.

if you’re writing your own token code then a pre check like this will work:

if whitelisted(principal) == true{
     transfer(from, to, amount)
}else{
    return Error
}

That is literally what the code does.