Feature request: allow fetched contracts to have their address changed
wei3erHase opened this issue · 1 comments
When fetching a contract type like a standard ERC20, it'd be nice to be able to fetch only 1 contract, and then to reuse it with several addresses:
import { getMainnetSdk } from '@dethcrypto/eth-sdk-client';
let sdk = getMainnetSdk(ethers.provider);
let erc20 = sdk.erc20
let dai = erc20.at('0x6b175474e89094c44da98b954eedeac495271d0f')
let mim = erc20.at('0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3')
In this way, even though we're not fetching the actual ABI, we're allowed to treat those contracts with a common interface and reduce loading time when compiling eth-sdk.
Very useful when working with several UniV3Pools that come from the same factory!
Very useful when working with a contract that's not deployed on mainnet but just on our test environment!
You can that you can already do that with attach
: (I am not sure what .at
does...`) https://docs.ethers.io/v5/api/contract/contract/#Contract-attach
As for having a dedicated syntax for this... I usually don't need that feature because ABI should be version-controlled so re-fetching ABI for similar contracts would happen only once...