Error: Could not fetch bytecode for contract at 0x20775d300BdE943Ac260995E977fb915fB01f399 on chain 137

    import { ThirdwebProvider, metamaskWallet, coinbaseWallet, walletConnect, phantomWallet } from           '   @thirdweb-dev/react';
    import { createThirdwebClient, getContract, resolveMethod } from 'thirdweb';
    import { defineChain } from 'thirdweb/chains';
    import { StateContextProvider } from './context';


    // Create the Thirdweb client with your clientId
    const client = createThirdwebClient({
      clientId: "bf783e8afe4c2547a9373fc7770da66e"
    });

    // Connect to your contract
    const contract = getContract({
      client,
      chain: defineChain(137),
      address: "0x20775d300BdE943Ac260995E977fb915fB01f399"
    });

    const root = ReactDOM.createRoot(document.getElementById('root'));

    root.render(
        <ThirdwebProvider 
        client={client}
    supportedWallets={[
        metamaskWallet({
            recommended: true,
        }),
    coinbaseWallet(),
    walletConnect(),
    ]}
    activeChain={'polygon'}
     clientId="bf783e8afe4c2547a9373fc7770da66e"
    >
        <Router>
            <StateContextProvider contract_info={contract}>
                <App />
            </StateContextProvider>
        </Router>
    </ThirdwebProvider>
    ) 

I have this code in my main.jsx. When i try const { contract } = useContract(contractAddress); in my stateContextProvider, i receive this error in my browser console.

console.js:273 Error: Could not fetch bytecode for contract at 0x20775d300BdE943Ac260995E977fb915fB01f399 on chain 137, double check that the address and chainId are correct.
at fetchContractMetadataFromBytecode (chunk-D5XVISX3.js?v=c52aa177:27087:11)
at async fetchContractMetadataFromAddress (chunk-D5XVISX3.js?v=c52aa177:27060:16)

The code below us the code for my StateContextProvider

    export const StateContextProvider = ({ children, contract_info }) => { 
      console.log(contract_info.address);
      console.log(contract_info.chain);
      onsole.log(contract_info.client);
      const contractAddress = contract_info.address
      const { contract } = useContract(contractAddress);

      const { mutateAsync: createCampaign } = useContractWrite(contract, 'createCampaign');  

        const address = useAddress(); //getting the address for our wallet
        const publishCampaign = async (form) => {
        try {
          const data = await createCampaign([
            address, // owner
            form.title, // title
            form.description, // description
            form.target,
            new Date(form.deadline).getTime(), // deadline,
            form.image,
          ])

           console.log("contract call success", data)
        } catch (error) {
          console.log("contract call failure", error)
        }
      }

      return (     
        <StateContext.Provider  
          value={{ 
            address,
            contract,
            createCampaign: publishCampaign,
          }}
        >
          {children} //we have to render the children in between our context state provider
        </StateContext.Provider>
      )
    }

I have confirmed that the contract address i have used is the right one from #thirdweb. I have also ensured the contractAddress is passed into my stateContextProvider by logging it to console. The code below is my stateContextprovider. I have confirmed that chain137 is my desired chain which is The Polygon network.

I do not expect to see that error, because of it,I cannot Create a Campaign succesfully.

New contributor

civir zach is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật