Replies: 4 comments 8 replies
-
|
I have the exact same question. I was thinking the need to use some code like this or perhaps a useCallback code that would change the buy call based on the collateral/currency type. But you need the two hooks to run concurrently in the root of the component. The only other way would be to drop these two options and look at something more programmatic creating the transaction yourself using more like the ethers apis themselves I fear. |
Beta Was this translation helpful? Give feedback.
-
|
=> create an array with contract address of native tokens on their chains + other coins since it would remain same.
give it a try |
Beta Was this translation helpful? Give feedback.
-
|
tried on avax, transaction initates but incorrect data. goerli failing to estimate gas fee. Looks it is impossible to implement this but i am trying maybe it work otherwise 2 hooks are solution |
Beta Was this translation helpful? Give feedback.
-
|
To be honest I don't think the hooks are the best way to achieve this. I tried and got something working using two hooks in two components and the components were enabled/disabled based on the currency (paymentType native/erc20) and I was still seeing the hook for the opposite currency throw errors occasionally as its state was updating slowly based on the currency change/reload semantics in next.js where I'm running this. Sushiswap have a nice method of doing a transaction call using a hook and memoized function, I think they have some kind of wagmi integration now, perhaps going there for some inspiration. From my side, its possible to have 2 components for the buy button in my case do different things based on the currency type of the transaction. You will get console errors but the UI seems to handle it ok. I think its messy and the hooks written are too specific to make it easy to do. I had to duplicate almost all the return values I needed (pre , tx and waiting tx) success and error values out of the hooks into my hook. I think look at the hook code in the repo and working out how to rewrite it yourself is a better option IMHO. Or just use ethers. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I tried like below....
As we can see, how do I handle two kinda transactions?
the input filed include not only eth also other tokens, so once when I input the amount over balance of according token, they give me error-'exceed the balance'. I wanted to build component that works in transactions of all tokens..
What are your thoughts?
Beta Was this translation helpful? Give feedback.
All reactions