forked from Tenderly/tenderly-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
38 lines (32 loc) · 1.15 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Interface } from 'ethers';
import { Tenderly, Network } from '../../lib';
import * as dotenv from 'dotenv';
import { counterContractAbi } from './counterContract';
dotenv.config();
const callerAddress = '0xDBcB6Db1FFEaA10cd157F985a8543261250eFA46';
const counterContract = '0x93Cc0A80DE37EC4A4F97240B9807CDdfB4a19fB1';
const counterContractAbiInterface = new Interface(counterContractAbi);
(async () => {
try {
const tenderly = new Tenderly({
accessKey: process.env.TENDERLY_ACCESS_KEY || '',
accountName: process.env.TENDERLY_ACCOUNT_NAME || '',
projectName: process.env.TENDERLY_PROJECT_NAME || '',
network: Network.SEPOLIA,
});
const transaction = await tenderly.simulator.simulateTransaction({
transaction: {
from: callerAddress,
to: counterContract,
gas: 20000000,
gas_price: '19419609232',
value: 0,
input: counterContractAbiInterface.encodeFunctionData('inc', []),
},
blockNumber: 3237677,
});
console.log('Simulated transaction:', transaction);
} catch (error) {
console.error('Error. Failed to simulate transaction: ', error);
}
})();