-
Notifications
You must be signed in to change notification settings - Fork 541
Add info on Tenderly #1006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add info on Tenderly #1006
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,143 @@ | ||||||
| --- | ||||||
| title: Tenderly | ||||||
| description: Tenderly is a comprehensive Web3 development infrastructure that enables developers to build, test, and monitor decentralized applications with support for Virtual TestNets and contract verification using both Hardhat and Foundry frameworks. | ||||||
| --- | ||||||
|
|
||||||
| # Tenderly | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this line — Docusaurus will pull the title from the front matter (line 2) |
||||||
|
|
||||||
| [Tenderly](https://tenderly.co?mtm_campaign=ext-docs&mtm_kwd=linea) is a full-stack Web3 development infrastructure that helps developers build, stage, test, and monitor decentralized applications. It provides Virtual TestNets for staging and testing in mainnet-like environments, with public and private verification support for both Hardhat and Foundry. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ## Create a Virtual TestNet | ||||||
| Both Hardhat and Foundry examples will use a Virtual TestNet as contract deployment and staging infrastructure. | ||||||
|
|
||||||
| Provision a [new Virtual TestNet](https://docs.tenderly.co/virtual-testnets/quickstart?mtm_campaign=ext-docs&mtm_kwd=linea) and place the RPC URL in the variable: | ||||||
|
|
||||||
| ```bash | ||||||
| export TENDERLY_VIRTUAL_TESTNET_RPC_URL=... | ||||||
| ``` | ||||||
|
|
||||||
| ## Foundry verification | ||||||
|
|
||||||
| To verify contracts with Foundry, follow the instructions in the [Tenderly documentation](https://docs.tenderly.co/contract-verification/foundry?mtm_campaign=ext-docs&mtm_kwd=linea). Tenderly offers etherscan-like verification API so all you need to do is use the correct [verification url](https://docs.tenderly.co/contract-verification#verification-on-tenderly-development-infrastructure??mtm_campaign=ext-docs&mtm_kwd=linea). | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| :::note | ||||||
|
|
||||||
| When working with Virtual TestNets, in case you use a custom chain ID, you also must [extend `foundry.toml`](https://docs.tenderly.co/contract-verification/foundry#extend-foundrytoml?mtm_campaign=ext-docs&mtm_kwd=linea) with information for the custom chain. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ::: | ||||||
|
|
||||||
| **1. `forge create` verification** | ||||||
| ```bash | ||||||
| TENDERLY_VERIFIER_URL=$TENDERLY_VIRTUAL_TESTNET_RPC_URL/verify/etherscan | ||||||
|
|
||||||
| forge create Counter \ | ||||||
| --rpc-url $TENDERLY_VIRTUAL_TESTNET_RPC_URL \ | ||||||
| --etherscan-api-key $TENDERLY_ACCESS_TOKEN \ | ||||||
| --private-key $DEPLOYER_PRIVATE_KEY \ | ||||||
| --verify \ | ||||||
| --verifier-url $TENDERLY_VERIFIER_URL | ||||||
|
|
||||||
| ``` | ||||||
|
|
||||||
| **2. `forge script` verification** | ||||||
| ```bash | ||||||
| TENDERLY_VERIFIER_URL=$TENDERLY_VIRTUAL_TESTNET_RPC_URL/verify/etherscan | ||||||
|
|
||||||
| forge script script/Counter.s.sol:CounterScript \ | ||||||
| --rpc-url $TENDERLY_VIRTUAL_TESTNET_RPC_URL \ | ||||||
| --private-key $DEPLOYER_PRIVATE_KEY \ | ||||||
| --etherscan-api-key $TENDERLY_ACCESS_TOKEN \ | ||||||
| --broadcast \ | ||||||
| --verify \ | ||||||
| --verifier-url $TENDERLY_VERIFIER_URL \ | ||||||
| --slow | ||||||
| ``` | ||||||
|
|
||||||
| **3. `forge verify` verification** | ||||||
| ```bash | ||||||
| TENDERLY_VERIFIER_URL=$TENDERLY_VIRTUAL_TESTNET_RPC_URL/verify/etherscan | ||||||
|
|
||||||
| forge verify-contract $COUNTER_ADDRESS \ | ||||||
| Counter \ | ||||||
| --etherscan-api-key $TENDERLY_ACCESS_TOKEN \ | ||||||
| --verifier-url $TENDERLY_VERIFIER_URL \ | ||||||
| --watch | ||||||
| ``` | ||||||
|
|
||||||
| ## Hardhat verification | ||||||
|
|
||||||
| To verify contracts with both `hardhat-verify` and `hardhat-ignition`, follow the instructions in the [Tenderly documentation](https://docs.tenderly.co/contract-verification/hardhat?mtm_campaign=ext-docs&mtm_kwd=linea). | ||||||
|
|
||||||
| **1. Install Tenderly CLI** | ||||||
|
|
||||||
| Install the [Tenderly CLI](https://github.com/Tenderly/tenderly-cli) and follow the prompts of `tenderly login`: | ||||||
|
|
||||||
| ```bash | ||||||
| brew tap tenderly/tenderly | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might be useful to add instructions for non-MacOS users to install |
||||||
| brew install tenderly | ||||||
| tenderly login | ||||||
| ``` | ||||||
|
|
||||||
| **2. Set up hardhat** | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| Extend `hardhat.config.ts` with following configuration: | ||||||
| - Add the `@tenderly/hardhat-tenderly` plugin | ||||||
| - Add the `tenderly_linea` network | ||||||
| - Add the `etherscan` plugin and configure it with the Tenderly | ||||||
| - Add the `tenderly` plugin configuration, and set up the Tenderly [`access key`](https://docs.tenderly.co/account/projects/how-to-generate-api-access-token?mtm_campaign=ext-docs&mtm_kwd=linea) and [`project` and `username`](https://docs.tenderly.co/account/projects/account-project-slug?mtm_campaign=ext-docs&mtm_kwd=linea) | ||||||
|
|
||||||
| ```typescript | ||||||
| import { HardhatUserConfig } from 'hardhat/config'; | ||||||
| import '@nomicfoundation/hardhat-toolbox'; | ||||||
| import '@tenderly/hardhat-tenderly'; | ||||||
|
|
||||||
| import * as dotenv from 'dotenv'; | ||||||
|
|
||||||
| dotenv.config(); | ||||||
|
|
||||||
| const config: HardhatUserConfig = { | ||||||
| solidity: '0.8.27', | ||||||
| networks: { | ||||||
| tenderly_linea: { | ||||||
| url: process.env.TENDERLY_ADMIN_RPC_URL_LINEA || "", | ||||||
| chainId: parseInt(process.env.TENDERLY_CHAIN_ID_LINEA || "-1"), | ||||||
| } | ||||||
| }, | ||||||
| etherscan: { | ||||||
| apiKey: { | ||||||
| tenderly_1: process.env.TENDERLY_ACCESS_KEY!, | ||||||
| tenderly_8453: process.env.TENDERLY_ACCESS_KEY!, | ||||||
| }, | ||||||
| customChains: [ | ||||||
| { | ||||||
| network: 'tenderly_linea', | ||||||
| chainId: parseInt(process.env.TENDERLY_CHAIN_ID!), | ||||||
| urls: { | ||||||
| apiURL: `${process.env.TENDERLY_ADMIN_RPC_URL}/verify/etherscan`, | ||||||
| browserURL: process.env.TENDERLY_ADMIN_RPC_URL!, | ||||||
| }, | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| tenderly: { | ||||||
| project: process.env.TENDERLY_PROJECT_NAME!, | ||||||
| username: process.env.TENDERLY_ACCOUNT_NAME!, | ||||||
| accessKey: process.env.TENDERLY_ACCESS_KEY!, | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| export default config; | ||||||
| ``` | ||||||
|
|
||||||
| **3. Verify the contract** | ||||||
|
|
||||||
| For `hardhat-ignition`, run the following command: | ||||||
| ```bash | ||||||
| npx hardhat ignition deploy ./ignition/modules/Counter.ts --network tenderly_linea --deployment-id deploy-1 | ||||||
| ``` | ||||||
|
|
||||||
| For `hardhat-verify`, run the following command: | ||||||
|
|
||||||
| ```bash | ||||||
| npx hardhat deploy --network tenderly_linea | ||||||
| ``` | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||
| --- | ||||||
| title: Tenderly | ||||||
| description: Tenderly offers specialized RPC methods for Linea blockchain developers to accurately estimate gas usage and predict optimal gas prices for upcoming blocks with probability-based transaction inclusion rates. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Again, just a suggestion, feel free to modify! |
||||||
| --- | ||||||
|
|
||||||
| Tenderly provides RPC methods to help developers estimate gas usage for a transaction, and predict gas price for the next block: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| - estimate gas on Linea with 100% accuracy with [`tenderly_estimateGas`](https://docs.tenderly.co/node/rpc-reference/linea/tenderly_estimateGas?mtm_campaign=ext-docs&mtm_kwd=linea) RPC method. This method estimates gas by profiling the transaction, and Tenderly ensures entire transaction runs fully, regardless of the initially provided gas for said transaction. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - predict gas prices for the next block using [`tenderly_gasPrice`](https://docs.tenderly.co/node/rpc-reference/linea/tenderly_gasPrice?mtm_campaign=ext-docs&mtm_kwd=linea) RPC method. Gas price prediction is based on historical data and statistical analysis, and it comes in 3 probability levels for transaction inclusion in the next block, including `maxFeePerGas`, `maxPriorityFeePerGas`, and transaction `waitTime`. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ## Use the Tenderly Gas API | ||||||
|
|
||||||
| To leverage Tenderly's Gas API, create an RPC Node and call the RPC methods: | ||||||
|
|
||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unneeded line here |
||||||
|
|
||||||
| **`tenderly_estimateGas`** | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ```bash | ||||||
| curl https://linea.gateway.tenderly.co/$TENDERLY_NODE_ACCESS_KEY \ | ||||||
| -X POST \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "jsonrpc": "2.0", | ||||||
| "id": 0, | ||||||
| "method": "tenderly_estimateGas", | ||||||
| "params": [ | ||||||
| { | ||||||
| "from": "0x8516feaea147ea0db64d1c5b97bb651ca5435155", | ||||||
| "to": "0x6b175474e89094c44da98b954eedeac495271d0f", | ||||||
| "data": "0xa9059cbb0000000000000000000000003fc3c4c84bdd2db5ab2cc62f93b2a9a347de25fb00000000000000000000000000000000000000000000001869c36187f3430000", | ||||||
| "value": "0x0" | ||||||
| }, | ||||||
| "21285787" | ||||||
| ] | ||||||
| }' | ||||||
| ``` | ||||||
|
|
||||||
| **`tenderly_gasPrice`** | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ```bash | ||||||
| curl https://linea.gateway.tenderly.co/$TENDERLY_NODE_ACCESS_KEY \ | ||||||
| -X POST \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "jsonrpc": "2.0", | ||||||
| "id": 0, | ||||||
| "method": "tenderly_gasPrice" | ||||||
| }' | ||||||
| ``` | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,52 @@ | ||||||
| --- | ||||||
| title: Tenderly | ||||||
| description: Tenderly offers robust monitoring and security solutions for Linea blockchain with features including configurable alerts, automated Web3 Actions, and simulation capabilities to predict transaction outcomes before execution. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| --- | ||||||
|
|
||||||
| Tenderly provides comprehensive monitoring and security solutions for Linea, allowing you to stay informed about on-chain events, and respond proactively to potential issues. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| - Configure [**Tenderly Alerts**](https://docs.tenderly.co/alerts/intro-to-alerts?mtm_campaign=ext-docs&mtm_kwd=linea) to get notifications on transactions and contract events, allowing you to stay aware of critical issues and to signal problems to external webhooks. Use the [Alert API](https://docs.tenderly.co/reference/api#/operations/createAlert?mtm_campaign=ext-docs&mtm_kwd=linea) for dynamic configuration and building more powerful triggering criteria. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - Use [**Web3 Actions**](https://docs.tenderly.co/web3-actions/intro-to-web3-actions?mtm_campaign=ext-docs&mtm_kwd=linea) to automate predefined responses, improving security and user experience. | ||||||
| - Leverage [**Simulation RPC**](https://docs.tenderly.co/simulations/single-simulations#simulate-via-rpc?mtm_campaign=ext-docs&mtm_kwd=linea) to predict transaction execution beforehand, and get insights about asset changes, state changes, and gas usage. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - It's possible to simulate single transactions with [`tenderly_simulateTransaction`](https://docs.tenderly.co/node/rpc-reference/linea/tenderly_simulateTransaction?mtm_campaign=ext-docs&mtm_kwd=linea) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - Simulate batches of interconnected transactions with [`tenderly_simulateBundle`](https://docs.tenderly.co/node/rpc-reference/linea/tenderly_simulateBundle?mtm_campaign=ext-docs&mtm_kwd=linea) | ||||||
|
|
||||||
| ``` | ||||||
| curl https://linea.gateway.tenderly.co/$TENDERLY_NODE_ACCESS_KEY \ | ||||||
| -X POST \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{ | ||||||
| "jsonrpc": "2.0", | ||||||
| "id": 0, | ||||||
| "method": "tenderly_simulateBundle", | ||||||
| "params": [ | ||||||
| [ | ||||||
| { | ||||||
| "from": "0xe2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2", | ||||||
| "to": "0x6b175474e89094c44da98b954eedeac495271d0f", | ||||||
| "data": "0x40c10f19000000000000000000000000e58b9ee93700a616b50509c8292977fa7a0f8ce10000000000000000000000000000000000000000000000001bc16d674ec80000" | ||||||
| }, | ||||||
| { | ||||||
| "from": "0xe58b9ee93700a616b50509c8292977fa7a0f8ce1", | ||||||
| "to": "0x6b175474e89094c44da98b954eedeac495271d0f", | ||||||
| "gas": "0x7a1200", | ||||||
| "data": "0x095ea7b3000000000000000000000000f7ddedc66b1d482e5c38e4730b3357d32411e5dd0000000000000000000000000000000000000000000000000de0b6b3a7640000" | ||||||
| }, | ||||||
| { | ||||||
| "from": "0xf7ddedc66b1d482e5c38e4730b3357d32411e5dd", | ||||||
| "to": "0x6b175474e89094c44da98b954eedeac495271d0f", | ||||||
| "gas": "0x7a1200", | ||||||
| "data": "0x23b872dd000000000000000000000000e58b9ee93700a616b50509c8292977fa7a0f8ce1000000000000000000000000bd8daa414fda8a8a129f7035e7496759c5af8570000000000000000000000000000000000000000000000000006a94d74f430000" | ||||||
| } | ||||||
| ], | ||||||
| "latest", | ||||||
| { | ||||||
| "0x6b175474e89094c44da98b954eedeac495271d0f": { | ||||||
| "stateDiff": { | ||||||
| "0xedd7d04419e9c48ceb6055956cbb4e2091ae310313a4d1fa7cbcfe7561616e03": "0x0000000000000000000000000000000000000000000000000000000000000001" | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| ] | ||||||
| }' | jq | ||||||
| ``` | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Descriptions need to be shorter in order to fit onto social cards, this is a suggestion, so feel free to modify