OpenZeppelin
Civilization saved 2 months of development time and >$100,000 of upfront investment while deploying CivTrade on 2 blockchains with just a few clicks in OpenZeppelin Defender
As a community-driven project, it’s sometimes difficult to guarantee high standards of service and technology delivery, while our team is not traditionally paid a salary and our income relies on donations which are naturally uncertain. But it’s important that CivTrade is reliably live 24/7!
Furthermore, guaranteeing security requires running code audits, complex affairs that only cover a relatively small part of the security value chain: logical bugs inside Solidity code. This process is both long and expensive. Our experience with Certik, which only finished on December 28th 2021 after $30,000 of upfront investment and 2+ months of unexplained delays, was less than stellar.
Furthermore, without a deployment platform we would need to keep track of multiple contract addresses on 5 different blockchains (2 for production — Ethereum mainnet & Polygon — plus 3 testnets — Kovan, Rinkeby, and Mumbai), manually perform monitoring, maintenance, and upgrade actions, and struggle to coordinate information across our global, cross-timezone dev team.
This would create huge security risks, so building a deployment environment from scratch was a non-starter for the Civilization team.
One option would have been to create a GitHub deploy pipeline to trigger admin processes in-house. However, this would have required developers to build, manage, and deploy a DevOps solution, adding at least 2 more months of work to our release schedule.
We estimated the costs of an in-house solution as:
- $40,000 in salaries for a full-time dev + full-time system administrator for the ~10 weeks required to build, test and deploy a new in-house system covering all our needs of deploy, monitor, alert etc.
- $30,000 in gas fees to deploy smart contracts on Ethereum, a conservative estimate given that every single complete contract deploy run cost us between $5,000 and $20,000 depending on gas prices; likely, without a professional deploy solution, the number of failed attempts would quickly add up and therefore cost of extra gas for more upgrades would be required
- $20,000 in server costs, to set up monitoring and reporting functions and keep them live reliably, with a 24/7 professionally high availability level and not just proof-of-concept
- $10,000–20,000 in software licenses for SQL Server Enterprise, Microsoft Windows Server, Email Server, and other necessary production-grade systems, depending on choice. Some open-source choices could help save money but then would increase the support burden on our team, not an easy choice.
Not only would this expensive service have been centralized and prone to bugs, but also it would have added significant development time and costs that can now instead be focused on building new products and features. Furthermore, it would have only covered the deploy/upgrade processes, but not the crucial monitoring, logging, and reporting activities required to run a professional, mission-critical trading service such as CivTrade.
Civilization shipped across 2 blockchain networks in less than 10 days through its technology integration with OpenZeppelin Defender: towards full decentralization, Defender offers CivTraders automated back-end smart contract deployment, monitoring, and reporting with extremely strong security, reliability, and performance guarantees from a world-class solution! And what’s best? The unbeatable initial price tag of $0 to get started.

Civilization chose to integrate the OpenZeppelin Defender platform and code because they were written by a team that performed over 150+ security audits already. And their contracts are literally the gold standard of security across DeFi today, countless tech projects and nearly ALL tokens rely on them.

OpenZeppelin provides ample documentation, support, and guidance, making it the easy-to-use solution for automated smart contract deployment and monitoring. Here is how we set it up.
First, added the following to the config file.
//add to hardhat.config.jsrequire(‘@openzeppelin/hardhat-upgrades’);require(‘@openzeppelin/hardhat-defender’);require(‘defender-relay-client/lib/ethers’);require(‘@civfund/hardhat-tasks/CivDeployTasks.js’);
Here we have:
- Upgrades Plugin makes smart contracts upgradeable. This requires moving constructors into initializer functions, where also all the initial state variable values must be set. And using the upgradeable version of the OpenZeppelin imports, which is a perfect mirror of the regular one. Huge gain for future expandability, minor effort, well documented online: totally worth it.
- Defender Plugin integrates key tasks into Hardhat directly, including publishing from script to web platform without any clicks. Read the excellent documentation about it.
- Relay Client removes the need to enter wallet private keys into .env text files locally, also providing better execution and gas management guarantees through relay wallet APIs. We are still building the code to further adopt this functionality ourselves, throughout our stack.
- Our Deploy Tasks providing one-line custom code extensions to Hardhat, while avoiding the use of clunky hardhat-deploy packages.
//add to env.js defenderApi: ‘’, defenderSecret: ‘’,
The env file contains our API keys for back-end connections. At this point, deployment is a matter of:
npx hardhat deploy-proxy --network mainnet --contract CivKeeper --proxy-address 0x73563b2(...)F23 add-to-defender
where the third parameter %job% can be:
- deploy-static: deploy a new static contract
- deploy-proxy: deploy a new proxy
- deploy-upgrade: upgrade an existing proxy contract.
Changes required to our core CivTrade contract? Zero.
Furthermore, we could also finally set up automated tests of our deploy script, which is crucial when you are working FIVE blockchains, and target to keep the SAME deploy address across each chain!
OpenZeppelin Defender allows us to automate what otherwise would have been done manually, removing errors and inefficiencies.
Here is where things get really cool:
A subset of our current Defender dashboard

All our smart contracts, across 5 different blockchains (production blockchains Ethereum mainnet, and Polygon plus 3 testnets Kovan, Rinkeby, and Mumbai), plus 5 multi-sign safes (one per blockchain), are all into a single, convenient monitoring dashboard!
Anyone from our global dev team, at any time of day 24/7, can watch the status of each contract through the Defender dashboard, and interact with it using a standardized interface with enterprise-grade logs.
For each contract, the key admin actions are tracked, and a new action is as simple as two clicks:

Even multi-signs are managed in a more user-friendly way than the rather clunky (non dev-friendly, more retail-oriented) interface of Gnosis.

Bonus: Hardhat scripts generate upgrade proposals directly inside the Defender web page, with clickable console.log links generated for you. For example (addresses redacted for security reasons):
Deploying contracts with the account: 0xFd2(...)0F63Account balance: 6.7042 MATICPreparing upgrade of: CivKeeper at 0x73563b2(...)F23Upgrade proposal created at: https://defender.openzeppelin.com/#/admin/contracts/matic-0x73563b2(...)F23/proposals/69a(...)-83c2-f09fbf15eeee
Few more clicks and you’re onto the multi-sign approval process, which again is UI-driven; a few additional clicks into Gnosis safe by each authorized signer, and you’re all onto beers with friends already!
The best part? The left navigation bar.

- Admin: the view seen above
- Relay: the wallet system driven by API for private key-less scripting, as shared above
- Autotask: running automated on-chain jobs, for example, we use this to check the LINK balance inside our Keeper contract and promptly top up as needed, subject to safety checks. We’ll further expand usage as we go along.

- Sentinel: monitoring and sending alerts. For security and scalability reasons, we implemented the checks on each CivTrade opened and closed across both production blockchains (Ethereum mainnet and Polygon). We did not want or need the same functionality on the 3 testnets. Note how pleasant, contract addresses are named? Makes it so much simpler to keep track of things.

This is not strictly a Defender feature, but still OpenZeppelin security-related, so it’s worth mentioning here. While researching Defender, we were so impressed that we decided to openly draw inspiration from OpenZeppelin’s new bug bounty program, to draft out our own bug bounty on Immunefi. Thanks mates, we already received very helpful advice and feedback from this!
Civilization is a successful community-driven project with a dedicated and highly skilled dev team, to which the OpenZeppelin Defender team provides world-class support around the clock: crucial to success. Kudos to Santiago Palladino & the whole OpenZeppelin team.
OpenZeppelin promptly replies to any of our questions 24/7, helping with crucial go-to-market support. This truly makes a difference!
While CivTrade continues to expand to all the blockchain networks supported by Uniswap v3, we look forward to continuing to expand our usage of OpenZeppelin features, so that our security and scalability will continue to improve over time.
Last modified 1yr ago