Tenderly Multi-Sig Wallet With Hardhat & Synpress

Travis Richardson

Technical Writer
This is an educational repo which demonstrates how you can test your smart contract using Tenderly DevNets for testing infrastructure, HardHat for Smart Contract tests, and Synpress for End-to-End testing.
By following along, you will learn how to verify and deploy your smart contracts using the Tenderly CLI, execute Hardhat tests, use Synpress & Playwright, run the Tenderly Debugger, and implement Continuous Integration tests with Github Actions to make sure it all works.

Introduction

Tenderly DevNets enable you to deploy, test, and integrate smart contacts on the latest network state. Powered by the Tenderly Simulation Infrastructure, this feature allows you to have your own private simulated network which you can share with your team.
In addition, Synpress allows you to perform end-to-end tests blah blah blah.
The following technologies are used:
Technology Description Tenderly DevNets Simulated Network for Testing Synpress & Playwright E2E Testing Framework Hardhat Local Testing Github Actions Continuous Integration (CI/CD) Multi-Sig-Wallet Ethereum Smart Contract Metamask & Rainbow Wallet Web3 Wallets

Setup

To set the project up, you will just need a new Tenderly Account and CLI installed.

1. Get Your Tenderly Account Set Up

First, you need a Tenderly account. To set up your account, register by following a few simple steps.
Go here and click the Generate Access Token button. Create your Token and record the value for later use when we set up GitHub Actions and Continuous Integration.
Next, install the Tenderly CLI and login with:
tenderly login

2. Set up a DevNet Template

Create a new project in Tenderly and name it: Mini Multisig.
Create a new DevNet Template, and name it: Mini Multisig Tests. (Devnets -> Create Template) If you need help, here is a link.
Copy and paste the following code for your YAML file:

Deployment

3. Spawn Your DevNet & Deploy with Hardhat

Run the command:
Open up packages/hardhat/hardhat.config.ts and add your username and project slug (mini-multisig) to the config.tenderly object.
Spawn a new Tenderly Devnet from the CLI using:
Deploy the contracts:

Testing

4. Run the Hardhat tests

To make the test run, please open up packages/hardhat/contracts/MultiSigWallet.sol and locate line 159 where we have: transaction.numConfirmations > signaturesRequired.
Change the expression by replacing line 159 with this line: transaction.numConfirmations >= signaturesRequired (changes the > to >=).
Execute the following:

5. Run the E2E tests (Synpress)

Execute the following:
Create a new folder in your project (create at the root level) named .github/workflows.
Inside the directory, create a new file named tests.yaml.
Paste the following into the tests.yaml file, and fill in the TENDERLY_ACCOUNT_ID with your username, replacing the "PASTE_YOUR_USERNAME" field:
Go to your GitHub repository, and create a Secret (Settings → Secrets and Variables → Actions)
Click New repository secret. Make sure the Name field is set to the following: TENDERLY_ACCESS_TOKEN. Then for the Secret field, supply any secret you like.
Paste your Tenderly Access Token in to GitHub secret, save, and close the popup in the dashboard. (You did this in the setup part of this repo)
Push your changes by executing the following:
Head over to GitHub and select the GitHub Actions tab. You should see your build running.

Other Useful Scripts

Last but not least, here are a two other notable scripts we have built that you might find save you time by combining steps.
Script Description "stage": "npm run devnet:minimultisigtests:new && hardhat run scripts/deploy.ts --network tenderly", This is a staging script which creates a new DevNet and deploys the multi-sig contracts to it. "test:devnet": "npm run devnet:minimultisigtests:new && hardhat test --network tenderly" This is a testing script which creates a new DevNet and runs the Hardhat tests.

Author

Travis Richardson (@tleerichardson)
Partner With Travis
View Services

More Projects by Travis