simulate-tx 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +103 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # simulate-tx
2
+
3
+ EVM transaction simulator — simulate what a tx will do before sending it.
4
+
5
+ Works on **any EVM chain** (Ethereum, Base, Arbitrum, Optimism, Polygon, BSC, etc.) and **EraVM chains** (ZkSync, Lens, Cronos zkEVM, Zircuit).
6
+
7
+ Powered by [revm](https://github.com/bluealloy/revm), compiled to WebAssembly.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install simulate-tx
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```javascript
18
+ const { simulate, simulateFromObject } = require('simulate-tx');
19
+
20
+ // From a JSON string
21
+ const result = await simulate('https://eth.llamarpc.com', JSON.stringify({
22
+ from: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
23
+ to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
24
+ data: '0x095ea7b3...',
25
+ value: '0x0',
26
+ chain_id: 1,
27
+ }));
28
+
29
+ // Or pass a JS object directly
30
+ const result = await simulateFromObject('https://base-rpc.publicnode.com', {
31
+ from: '0x...',
32
+ to: '0x...',
33
+ data: '0x...',
34
+ value: '0x0',
35
+ chain_id: 8453,
36
+ });
37
+ ```
38
+
39
+ ## Output
40
+
41
+ ```javascript
42
+ {
43
+ success: true,
44
+ gas_used: 55582,
45
+ return_data: '0x...0001',
46
+ revert_reason: null, // decoded string if tx reverts
47
+ effects: [
48
+ {
49
+ type: 'Erc20Approval',
50
+ token: '0xa0b8...',
51
+ owner: '0xd8da...',
52
+ spender: '0x6e4c...',
53
+ value: '0x2386f26fc10000'
54
+ }
55
+ ],
56
+ logs: [...], // raw event logs (EVM chains only)
57
+ calls: [...] // internal call trace
58
+ }
59
+ ```
60
+
61
+ ## Effect types
62
+
63
+ | Type | Description |
64
+ |------|-------------|
65
+ | `NativeTransfer` | ETH/native token transfer |
66
+ | `Erc20Transfer` | ERC-20 transfer |
67
+ | `Erc20Approval` | ERC-20 approve |
68
+ | `Erc721Transfer` | NFT transfer |
69
+ | `Erc1155TransferSingle` | ERC-1155 single transfer |
70
+ | `Erc1155TransferBatch` | ERC-1155 batch transfer |
71
+ | `ApprovalForAll` | Operator grant (ERC-721/1155) |
72
+ | `Permit` | EIP-2612 permit |
73
+ | `Permit2Approval` | Uniswap Permit2 |
74
+ | `ContractCreated` | New contract deployed |
75
+ | `SelfDestruct` | Contract self-destructed |
76
+
77
+ ## Input fields
78
+
79
+ | Field | Type | Required | Description |
80
+ |-------|------|----------|-------------|
81
+ | `from` | address | yes | Sender |
82
+ | `to` | address | no | Recipient (omit for contract creation) |
83
+ | `data` | hex string | yes | Calldata |
84
+ | `value` | hex uint256 | yes | Wei to send |
85
+ | `chain_id` | number | yes | Chain ID |
86
+ | `block_number` | number | no | Block to fork from (default: latest) |
87
+ | `gas_limit` | number | no | Gas limit (default: 30M) |
88
+
89
+ ## How it works
90
+
91
+ - **EVM chains**: forks state via `eth_createAccessList`, prefetches in parallel, executes in revm with an inspector
92
+ - **EraVM chains**: parallel `eth_call` + `debug_traceCall`, decodes effects from calldata
93
+
94
+ Engine is auto-selected by chain ID.
95
+
96
+ ## Links
97
+
98
+ - [GitHub](https://github.com/kkpsiren/rtxsimulator)
99
+ - [CLI & Rust library docs](https://github.com/kkpsiren/rtxsimulator#readme)
100
+
101
+ ## License
102
+
103
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simulate-tx",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "EVM transaction simulator — simulate what a tx will do before sending it",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,8 @@
21
21
  "files": [
22
22
  "simulate_tx_bg.wasm",
23
23
  "simulate_tx.js",
24
- "simulate_tx.d.ts"
24
+ "simulate_tx.d.ts",
25
+ "README.md"
25
26
  ],
26
27
  "main": "simulate_tx.js",
27
28
  "types": "simulate_tx.d.ts"