-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.ts
38 lines (32 loc) · 1.2 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 dotenv from 'dotenv';
import { Interface } from 'ethers';
import { counterContractAbi } from './counterContract';
import { Tenderly, Network, getEnvironmentVariables } from '../../lib';
dotenv.config();
const callerAddress = '0xDBcB6Db1FFEaA10cd157F985a8543261250eFA46';
const counterContract = '0x93Cc0A80DE37EC4A4F97240B9807CDdfB4a19fB1';
const counterContractAbiInterface = new Interface(counterContractAbi);
(async () => {
try {
const tenderly = new Tenderly({
accessKey: getEnvironmentVariables().TENDERLY_ACCESS_KEY,
accountName: getEnvironmentVariables().TENDERLY_ACCOUNT_NAME,
projectName: getEnvironmentVariables().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);
}
})();