PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 183 forks source link

hot fix on 02-update-front-end.js #191

Closed stevegee1 closed 9 months ago

stevegee1 commented 9 months ago

multiple runs on 02-update-front-end.js creates multiple addresses, with the most recent address at the last index with this code snippet: contractAddresses[network.config.chainId.toString()].push(raffle.address)

This code snippet: const raffleAddress = chainId in contractAddresses ? contractAddresses[chainId][0] : null refers to the first index not the most recent address @PatrickAlphaC

instead, we can overwrite the contractAddress.json with the most recent address with this code snippet:

contractAddresses[network.config.chainId.toString()]=raffle.address This overwrites the array with the most recently deployed address Thanks @PatrickAlphaC @stevegee1

PatrickAlphaC commented 9 months ago

Smart!