-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DX Improvement: add local abi source option #65
Comments
Just found a potential workaround in another issue:
Guess that works but it's just a workaround, would be nice to have an officially supported way of using local abi sources. |
@agcty I feel your pain. This is definitely something that we should support but the problem is that on localhost, often, all addresses are random. I thought that in this case, we should expose more general methods like |
Understand what you mean now, the problem is rooted a little deeper than I thought. I think there are 2 approaches eth-sdk could potentially take. Approach 1 (current approach): Benefits
Downsides
I think the best way would be to allow for maximum flexibility while still maintaining ease of use by offering a function that returns only the classes but not already the instantiation. Approach 2:
This would allow for maximum flexibility because you'd be able to create an instantiation of a contract at runtime like this:
In addition, this would allow you to use different providers if needed. Pretty nice free added benefit imo. Benefits
Now we made it much more flexible but was this at the cost of ease of use? No. eth-sdk could just offer a wrapper function getInstantiatedSDK() (literally getSDKWithoutAddresses but just renamed) that takes a list of addresses as a parameter and uses getSDK under the hood (would also make it backwards compatible). Let me know what you think, also always happy to jump on a call if something doesn't make sense! Edit: Would also solve #43 |
Thanks for spending time writing this down. I like this proposal. It's inline with how I was thinking about it. The problem is that each network can list different addresses + some contracts might now be even deployed on any network and requires providing ABI manually (we could allow specifying abi path instead of address for a special network called "local"). It would be awesome if you would want to develop this feature. As a next step I would love to see a detailed written proposal and discuss with exact code examples etc. |
@krzkaczor yes would love to spend some time on this and write a proposal, give me some time :) |
Crazy idea people, but is it easier to mock the etherscan api on the localhost/hardhat side? Like a Hardhat plug-in that spins up express server on a port Keeps this beautiful library focused and isolates the use case for other potential applications |
Adding the ABIs manually worked, but the directory name must be plural, |
Fetching ABIs from etherscan or sourcify is great but only works if the contracts are already deployed and verified. But how do you work with contracts that are not yet deployed?
Would like to build different frontend environments: local (npx hardhat node) / staging (e.g goerli) / production (e.g mainnet)
I'm working on some local smart contracts with hardhat and don't want to deploy them just yet, I just want to play around locally and have my frontend pick up all the right types. Seems like I can't do that at the moment (or haven't found a way by looking through the docs).
Something like that would improve DX by 100x
Basically allowing you to opt in to use a local abi for any contract. There is also the possibility of defining that all local contracts should fetch the abi from a local source and do some filename lookup but having a granular approach that lets you choose where the abi is coming from for each contract is better IMO because you might be working with some contract that is not verified for some reason but you still have the abi. So you could mix verified contracts on mainnet with unverified ones where you still have the abi for example. (Note: All contracts should be verified but this use case is still valid IMO)
For context, to use this in a frontend I'd probably create a custom hook that gets the current network name from an env file and returns the correct SDK.
Like this (pseudo-code):
Let me know if I can help in any way to support this :)
The text was updated successfully, but these errors were encountered: