Created
July 21, 2022 21:35
-
-
Save anonymoussprocket/e3b7992604cfefaa419dd60f54d3f876 to your computer and use it in GitHub Desktop.
Mock a mainnet contract dynamically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from 'node-fetch'; | |
import { smock } from '@defi-wonderland/smock'; | |
async function deployMockContractFromAddress(contractAddress: string, etherscanKey: string) { | |
const abi = await fetch(`https://api.etherscan.io/api?module=contract&action=getabi&address=${contractAddress}&apikey=${etherscanKey}`) | |
.then(response => response.json()) | |
.then(data => JSON.parse(data['result'])); | |
return smock.fake(abi, {address: contractAddress}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
smock docs