Wrong USDC address used in Deploy.s.sol script causing the MerkleAirdrop contract cannot be used as intended
Deploy.s.sol script using 0x1D17CbCf0D6d143135be902365d2e5E2a16538d4 instead of 0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4 would break the contract deployed because the former is not an ERC20 address instead it is a normal address. So it does not have safeTransfer function called on MerkleAirdrop::claim function.
Deploy.s.sol:
Add your zksync rpc url ZKSYNC_MAINNET_RPC_URL to .env file.
Add this helper code to Deploy.s.sol so our test can capture the address of MerkleAirdrop and IERC20 contract:
Add MerkleAirdropDeployScriptTest.t.sol to test folder.
MerkleAirdropDeployScriptTest.t.sol:
after that run the following command forge test --zksync --fork-url $ZKSYNC_MAINNET_RPC_URL --mt testUsingDeployScriptContractBrokenBecauseWrongUSDCAddress
the result should REVERT:
Contract MerkleAirdrop broken and cannot be used.
manual review and foundry
Change the Deploy.s.sol value of s_zkSyncUSDC to correct value 0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4.
Deploy.s.sol:
furthermore on MerkleAirdrop contract, we can add check whether the variable passed on constructer is smartcontract or not. This is not a silver bullet solution as there are problems like passing wrong ERC20 address too. But for this specific problem in this audit, this can help mitigating passing EOA address instead of contract address.
MerkleAirdrop.sol:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.