Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ To achieve this, just send a transaction with any `from` address:
```tsx
...
dotenv.config();
const { TENDERLY_USER, TENDERLY_PROJECT, TENDERLY_ACCESS_KEY } = process.env;
const { TENDERLY_USER, TENDERLY_PROJECT, TENDERLY_ACCESS_KEY, TENDERLY_FORK_ID } = process.env;

const SIMULATE_API = `https://api.tenderly.co/api/v1/account/${TENDERLY_USER}/project/${TENDERLY_PROJECT}/simulate`
const SIMULATE_API = `https://api.tenderly.co/api/v1/account/${TENDERLY_USER}/project/${TENDERLY_PROJECT}/fork/${TENDERLY_FORK_ID}/simulate`;

const provider = new ethers.providers.JsonRpcProvider(process.env.TENDERLY_FORK_URL);

const DAI_ADDRESS = "0x6b175474e89094c44da98b954eedeac495271d0f";

// tx data obtained using other means
const TX_DATA = await contract.populateTransaction[funcName](...args);
// DAI contract instance
const dai = ERC20__factory.connect(DAI_ADDRESS, provider);

const TX_DATA = await dai.populateTransaction[funcName](...args);

const transaction = {
network_id: '1',
from: "0x0000000000000000000000000000000000000000",
input: TX_DATA,
input: TX_DATA.data,
to: DAI_ADDRESS,
block_number: null,
// tenderly specific
Expand All @@ -32,9 +36,16 @@ const transaction = {

const opts = {
headers: {
'X-Access-Key': process.env.TENDERLY_ACCESS_KEY || "",
"content-type": "application/JSON",
'X-Access-Key': TENDERLY_ACCESS_KEY || "",
}
}
const resp = await axios.post(SIMULATE_API, transaction, opts);
console.log(resp.data);

try {
const resp = await axios.post(SIMULATE_API, transaction, opts);
console.log(resp.data);
} catch (err: any) {
console.log(err.response.data.error);
}

```