How do I restrict project id usage to a specific contract correctly?

If I add a filter with any contract address and attempt to transact to that contract address using ethers.js, then it always gives me an error “rejected due to project ID settings”. So it appears that I should probably try to add something else also? If I am also required to add an address that is transacting, then functionality has to be improved I believe.
Is using an additional centralized server to store the project ID and relay users’ transactions to Infura nodes the only way?
Update: just checked, totally works if I add address that is transacting to that contract. Explanation is misleading, this option is completely something else rather than “ALLOWLIST CONTRACT ADDRESSES”
Ok, I will have to use a centralized server for it I guess

Hi @Snake, and welcome to the Infura community!
Glad you figured it out, and thank you for posting your solution so others who run into this issue can reference it!

1 Like

Thanks for the welcome, glad to be here!
Well, ok. it is not possible at all it seems.

Please allow using exposed project IDs somehow. It’s important
Also, I would like to know if it’s possible to at least restrict requests per second not for project ID in general, but for client IPs in particular.

We do allow users to use exposed Project IDs, but suggest if you are taking that route that you use one of our other options for securing the public Project ID instead (i.e. a Project Secret or whitelisting) - you can read more about options for project security here.

As far as the restrictions go, as of right now it’s not possible to restrict by client IPs. If that changes, we will be sure to update the community, but there aren’t any plans in the near future for that.

1 Like