Skip to content
RED SAGSkills
mediumBlockchain Developer interview question

How do you test a smart contract before deploying it to mainnet?

What the interviewer wants to hear

  • Unit tests for every function and revert path
  • Fuzz and invariant tests
  • Mainnet fork tests with real integrations
  • Static analysis tools like Slither
  • Testnet deployment, audits and bug bounties
  • Deployment scripts and verification tested too

Model answer

I write unit tests in Foundry for every function, including all revert paths and access control, checking events and balances. Then fuzz tests that run functions with random inputs, and invariant tests that call random sequences of functions and check properties that must always hold, such as total shares matching total deposits or the protocol never owing more than it holds. For integrations with tokens, oracles or DEXs, I run fork tests against a mainnet snapshot so the behaviour is real, including odd tokens like fee-on-transfer ones. I run static analysis with Slither and check coverage. Deployment scripts are tested on a fork and a public testnet like Sepolia, and contracts are verified on the explorer. For anything holding real value, an external audit, sometimes formal verification of key properties, and a bug bounty come before launch, plus monitoring and a pause plan after.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Blockchain Developer questions