Back to All

creating a provider?

seems like something has broken in the SDK

based on this code:

https://docs.alchemy.com/docs/how-to-mint-an-nft-from-code#step-1-create-an-alchemy-provider-using-ethers

const provider = new ethers.providers.AlchemyProvider('mumbai', apiKey);

gives

TypeError: Cannot read properties of null (reading 'name')
node_modules/@ethersproject/providers/src.ts/alchemy-provider.ts:57
        switch (network.name) {

I also tried passing an object

const netObj = {
    // name: 'MATIC_MUMBAI',
    name: 'polygon-mumbai',
    // chainId: 80001  // FIXME
}

using

"alchemy-sdk": "^2.0.2",

OK so the working magic codes are:

const netObj = {
    // name: 'MATIC_MUMBAI',
    // name: 'polygon-mumbai',
    name: 'maticmum',
    chainId: 80001  // hardwired bullshit
}
const provider = new ethers.providers.AlchemyProvider(netObj, apiKey);

is there a way to get the hardwired chainId somehow?

ReadMe