Relay - multiple (derived) keys/addresses


I'm hoping to use Defender in a project I'm working on but I need to generate/manage and sign using multiple wallets. I like how relays are able to manage keys for me and take care of the complexity of direct interaction with the blockchain, but is there a way to get more than one signer out of a relay, i.e.. HD-style addresses generated from the private key it holds?

If not then I think this would be a great feature to add!


Thanks for getting in touch @zep!

You have an interesting use case. Can you elaborate on what you want to achieve?

Sometimes we find that using a combination of our already existing tools can solve many use cases.

Well, among other things, I'm looking to implement an exchange-like system where users are able to deposit funds with us. We need to support transfers directly from exchanges or other sources where the user might not directly control the wallet holding the tokens.

So the plan is to give each user a unique address and then auto-sweep the tokens into a smart contract as they arrive.

The part where the addresses are monitored is also an issue I need to solve. Whether we have to manage the derived keys/addresses manually or not, we'll need to keep track of token transfers to all the addresses under management. Is this a reasonable/viable thing to do with a sentinel:

  • Set it up to monitor several ERC-20 tokens. Some will be popular (high-traffic) tokens like WETH or USDC.
  • Every time we generate a new address for a user, we use the API to add a new address filter to the sentinel.

I don't know how many users we are likely to have, but if we needed hundreds or thousands of addresses (thus a filter for each would be needed), would a sentinel support that?

Also how robust are sentinel web hooks? What if our web hook endpoint is down or returns an error? Would the sentinel retry or is that event lost?

Another question. Sorry for all the posts. In my account plan, it says:

"All autotasks can cumulatively run up to 120 times per hour. Each autotask has a minimum frequency of 1 minute."

Do these limits also apply to autotask invocations from a sentinel? I.e., if my sentinel sees 200 events on the contract it's monitoring, will 80 of them not be acted upon? And will the min frequency be enforced here?

Hey @zep! Unfortunately Relayer does not support HD-like addresses, and we are limited in building that feature since it's not supported by the underlying KMS solution we use. One option would be to spin up one relayer per user, but this would require a custom plan which may end up being quite expensive (I can contact you with our sales team though if you want to discus).

A simpler solution may be to just spin up smart wallets for your users. You can write a simple contract that only has logic for forwarding the erc20s it holds into a separate contract, and deploy one per each user you work with. You can even delay deploying it until there are actually funds to sweep, and use some CREATE2 magic to know the deployment address before deploying.

With this, you can have a single relayer that can call sweep on all smart accounts. Even better, since each user's wallet is not an EOA but a contract, you can easily batch multiple transfers on a single tx to save gas.

Hi @zep,

Re the autotask limits.
Yes, these limits apply to the autotask invocations from a sentinel as well. You will be notified about the limit reached and will need to upgrade the plan. If you are anticipating your application to reach these limits, I would recommend getting in touch and upgrading beforehand to avoid any disruptions.

Re adding new addresses to the sentinel.
There’s no hard limit at the moment, but due to implementation constraints in practice, it’ll amount to a couple of thousand monitored addresses.

We are aware that the UI will get messy to the point of being unusable if you add many addresses.
We’ll try to fix that, but in the meantime, your only reasonable option would be to manage sentinel via API.

We haven’t yet encountered the use case of monitoring thousands or even more of addresses with a single sentinel, so that particular scenario is currently untested. We will be looking into it in a near future.

Re webhooks:
The event would be lost in this situation.

I hope this answers your questions!

Thanks guys - that is helpful.

The CREATE2 trick is pretty neat but I imagine it would be expensive to be putting up contracts on Ethereum.

I'll think over the options - we may be in touch to get a plan set up if we decide on doing something non-trivial with your services.

It would be nice if I could attach metadata to an EventCondition, i.e. an object (or just a string) that gets passed through to the autotask.