Sean Ng
Sean Ng

Reputation: 23

Why am I getting 0x from provider.getCode?

I've deployed my contract on the correct network (rinkeby) as seen here. I've also connected my wallet address to the dApp selecting the correct network. I have run npx hardhat compile to update my contract artifact. However, when I try to run provider.getCode(contractAddress), it returns with 0x, and I can't figure out why.

const contractAddress = '0x1Fc7Fe607BA2481Ff492814C27943dEdB8cBA0cE'
const provider = await web3Modal.connect()
const web3Provider = new ethers.providers.Web3Provider(provider)
console.log(await web3Provider.getCode(contractAddress)) // returns 0x

Upvotes: 0

Views: 858

Answers (1)

Crazy Punch Man
Crazy Punch Man

Reputation: 126

Because it is address, the address will return 0x, it is also possible that your node is wrong and not on the right chain . Because the address I saw on the Goerli testnet is the contract, and the link you provided is the Rinkeby testnet. :)

Upvotes: 1

Related Questions