Skip to content

Commit

Permalink
Virtual testnets examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nvitorovic committed Apr 24, 2024
1 parent 656d43c commit 3c74573
Show file tree
Hide file tree
Showing 146 changed files with 21,228 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/virtual-testnets-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Staging contracts and updating others
on: push
jobs:
deploy_to_testnet:
name: Deploy Contracts To TestNet
runs-on: ubuntu-latest
env:
TENDERLY_ACCESS_KEY: ${{secrets.TENDERLY_ACCESS_KEY}}
DEPLOYER_PRIVATE_KEY: ${{secrets.DEPLOYER_PRIVATE_KEY}}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20.12.0
cache: npm

- name: Install
uses: npm ci

- name: deploy
working-directory: virtual-testnets-staging/foundry
run: deploy
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ build/Release

# Dependency directories
node_modules/
**/node_modules/
jspm_packages/

# TypeScript v1 declaration files
Expand Down Expand Up @@ -79,4 +80,6 @@ typings/

# macOS
.DS_Store
.devnet
.devnet
/virtual-testnets/node_modules/
*.out
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "hello_virtual_testnets/lib/forge-std"]
path = hello_virtual_testnets/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "virtual-testnets-staging/contracts-foundry/lib/forge-std"]
path = virtual-testnets-staging/contracts-foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "virtual-testnets-state-sync/contracts/lib/forge-std"]
path = virtual-testnets-state-sync/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@

## Introduction

This repository contains examples showcasing the [Tenderly development platform](https://tenderly.co). Usually every example is accompanied by a blog post.
This repository contains examples showcasing the [Tenderly development platform](https://tenderly.co). Usually every
example is accompanied by a blog post.

## Examples

| Example name | Blog post | Repository Link |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| Proxy Contracts Verification with Hardhat scripts and Tenderly DevNets | [Deploying and Verifying Proxy contracts with Tenderly hardhat](https://docs.tenderly.co/monitoring/smart-contract-verification/verifying-contracts-using-the-tenderly-hardhat-plugin/verifying-proxy-contracts-on-tenderly) |
| Example name | Blog post / Docs | Repository Link |
|------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| Using Tenderly Node with Ethers 5 | [Using Tenderly Node](https://docs.tenderly.co/node) | [node & ethers5](/node/) |
| Using Tenderly Node with Ethers 6 | [Using Tenderly Node](https://docs.tenderly.co/node) | [node & ethers 6](/node/) |
| Using Tenderly Node with Viem | [Using Tenderly Node](https://docs.tenderly.co/node) | [node & viem](/node/) |
| Using Simulation RPC | [Using Simulation RPC](https://docs.tenderly.co/simulations) | [node](/simulations/rpc/mainnet/) |
| Using Simulation API | [Using Simulation API](https://docs.tenderly.co/node) | [node](/simulations/api/base) |
| Proxy Contracts Verification with Hardhat scripts and Tenderly DevNets | [Deploying and Verifying Proxy contracts with Tenderly hardhat](https://docs.tenderly.co/monitoring/smart-contract-verification/verifying-contracts-using-the-tenderly-hardhat-plugin/verifying-proxy-contracts-on-tenderly) | [proxy verification](/contract-verifications/) |
| Multi-Sig wallet | [How to Deploy an Ethereum Multi-Signature Wallet With Hardhat and Tenderly](https://blog.tenderly.co/how-to-deploy-an-ethereum-multi--signature-wallet-with-hardhat-and-tenderly/) | [multisig-wallet](https://github.com/Tenderly/tenderly-examples/tree/master/multisig-wallet) |
| Multi-Sig Wallet UI With Simulations | N/A | [multisig-ui-simulations](https://github.com/Tenderly/tenderly-examples/tree/master/multisig-ui-simulations) |
| Simple Solidity Calculator | [How to debug Solidity Smart Contracts with Tenderly and Truffle](https://blog.tenderly.co/how-to-debug-solidity-smart-contracts-with-tenderly-and-truffle/) | [simple-solidity-calculator](https://github.com/Tenderly/tenderly-examples/tree/master/simple-solidity-calculator) |
| Tennis Match | [Debugging Ethereum transactions just got a whole lot easier!](https://blog.tenderly.co/debugging-ethereum-transactions-just-got-a-whole-lot-easier/) | [tennis-match](https://github.com/Tenderly/tenderly-examples/tree/master/tennis-match) |
| Virtual TestNets & State Sync | N/A | [virtual-testnets-state-sync](./virtual-testnets-state-sync) |

# Contributing

Expand Down
2 changes: 1 addition & 1 deletion multisig-wallet/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const config: HardhatUserConfig = {
tenderly: {
// tenderly network used for running tests
chainId: 736031,
url: "https://rpc.vnet.tenderly.co/devnet/mini-safe/fbdd9913-7e93-4d93-88fb-f41dddd9856d",
url: "https://rpc.vnet.tenderly.co/devnet/mini-safe/fedd6378-d4c8-49fd-b96d-3d4950cb5195",
},

// Sepolia config in case you still want public testnets
Expand Down
12 changes: 12 additions & 0 deletions node/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.tenderly.co/account/projects/account-project-slug
export TENDERLY_ACCOUNT_ID=...
export TENDERLY_PROJECT=...

# https://docs.tenderly.co/account/projects/how-to-generate-api-access-token
export TENDERLY_ACCESS_KEY=...

# https://docs.tenderly.co/node
export TENDERLY_NODE_ACCESS_KEY=...

## Private key to sign test transactions
export PRIVATE_KEY=0x...
55 changes: 55 additions & 0 deletions node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Node Examples

This section contains examples on usage of Tenderly node via:

- [Ethers 5](ethers-5/)
- [Viem examples](ethers-6/)
- [Viem examples](samples/viem)

## Environment setup

Set up environment variables:
- **`TENDERLY_ACCOUNT_ID`** with your [account ID](https://docs.tenderly.co/account/projects/account-project-slug)
- **`TENDERLY_PROJECT`** with your [project (slug)](https://docs.tenderly.co/account/projects/account-project-slug)
- **`TENDERLY_ACCESS_KEY`** with
the [access key you've generated](https://docs.tenderly.co/account/projects/how-to-generate-api-access-token)
- **`PRIVATE_KEY`** for signing test transactions
- **`ORIGINAL_NETWORK_ID`** with the [ID of the network](https://docs.tenderly.co/supported-networks-and-languages) you
want to base the TestNet on

```bash
cp .env.example .env
vi .env # modify environment variables
```

## Running the samples

### Viem

```bash
source .env
cd samples/viem
yarn
npx ts-node 0-batch-calls.ts
npx ts-node 0-send-tx.ts
```

### Ethers 5

```bash
bash .env
cd ethers-5
yarn
npx ts-node json-rpc-https-provider.ts
```

### Ethers 6

```bash
bash .env
cd ethers-6
yarn
npx ts-node json-rpc-https-provider.ts
```


13 changes: 13 additions & 0 deletions node/ethers-5/json-rpc-https-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Installation Instructions: https://docs.ethers.io/v5/getting-started
import { ethers } from "ethers";

const RPC_URL = `https://mainnet.gateway.tenderly.co/${process.env.TENDERLY_NODE_ACCESS_KEY}`;

await (async () => {
// Initialize an ethers provider instance
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);

const blockNumber = await provider.getBlockNumber();

console.log(blockNumber);
})();
13 changes: 13 additions & 0 deletions node/ethers-5/json-rpc-wss-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Installation Instructions: https://docs.ethers.io/v5/getting-started
import { ethers } from "ethers";

const RPC_URL_WSS = `wss://mainnet.gateway.tenderly.co/${process.env.TENDERLY_NODE_ACCESS_KEY}`;

await (async () => {
// Initialize an ethers provider instance
const provider = new ethers.providers.WebSocketProvider(RPC_URL_WSS);

const blockNumber = await provider.getBlockNumber();

console.log(blockNumber);
})();
12 changes: 12 additions & 0 deletions node/ethers-5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "simulations",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@types/node": "^20.12.7",
"ethers": "^5.7.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
}
}
Loading

0 comments on commit 3c74573

Please sign in to comment.