-
Notifications
You must be signed in to change notification settings - Fork 130
Documentation Request: use contract hook with contract address passed as param #280
Comments
These are defined per contract type, in |
for a factory pattern, it's not obvious how to generate contract hooks where the address is dynamically passed from a frontend component |
out of curiosity, why the address is dynamic? |
I just mean dynamically passed. the current hook examples hardcode the contract address. |
Can you show us a code example on how you think it should behave, so I can better follow the type of developer experience you wish to have. And thank you again for helping us shape this. We really appreciate your input. |
code below does not work obviously.
I hacked this clunky version quickly and it works, but I'm sure there's a way to do it nicely with generateContractHook:
|
@Sneh1999 thoughts on this one? |
@michaelcohen716 we are actually building onchain-kit which will provide utilities/functions which are generic similar to what you are requesting. Build on chain apps on the other hand can be thought of more like a toolkit which gives you already setup end to end web3 examples/experiences of common use cases. When onchain-kit gains momentum, you will see us replacing a lot of common functionality. We will add documentation for functions like these within onchain-kit itself and just use them here. CC @Zizzamia feel free to add your thoughts |
I still believe the hook, should not be dynamic, as that could cause some security issue. I still don't understand the use case for @michaelcohen716 what am I missing? Can you share a bit more what are you trying to build. |
hey - i think me calling it "dynamically passed" is tripping the conversation up. i'm really just asking about any factory pattern. like, if i was building uniswap, how would i generate a hook for an individual pool. there are thousands, so I need to pass the contract address for a specific pool |
i would probably dispute the "edge case" characterization. it would be necessary for many AMMs or NFT marketplaces. I figured out how to do it, but a basic hook standard in the docs could be useful to others. not a huge deal either way, didn't mean to blow this out of proportion as mission critical or anything |
@michaelcohen716 sorry for the delay here, this got lost in a bunch of GH notifications. When you said
What issue did you run into? Something like the following should work (haven't had a chance to try, just made sure it typechecked) export const useCoffeeContract = (contractAddress: `0x${string}`) => generateContractHook({
abi: CoffeeABI, // instances of CoffeeContract
[baseSepolia.id]: {
chain: baseSepolia,
address: contractAddress,
},
}); |
All good, we just really love unpack each case scenario. :) |
Is your documentation request related to a problem? Please describe.
Current generateContractHook hooks have fixed addresses. Documentation requested for passing the contract address to that hook
The text was updated successfully, but these errors were encountered: