mirror of
https://github.com/luxfi/safe-wallet.git
synced 2026-10-30 15:19:21 +00:00
* chore: migrate tx-builder from safe-apps repo to this monorepo create-react-app is deprecated and I’ve migrated the code to vite. web3 is deprecated and I’ve moved the code to ethersjs the cypress tests were broken and I dropped them original code used mui4 -> here we’ve migrated to mui6 * fix(tx-builder): remove build from tx-builder * fix(tx-builder): vite config * fix(tx-builder): linting * fix(tx-builder): fix typo * fix(tx-builder): don’t mutate array * fix(tx-builder): fix exponential backtracking * fix(tx-builder): git workflows * fix(tx-builder): fix lint setup * fix(tx-builder): align package dependencies * fix(tx-builder): invalid react-dom version * fix(tx-builder): git workflow * fix(tx-builder): drag and drop was not working react-beautiful-dnd was no longer supported and it was not compatible with react 19. Moved to @hello-pangea/dnd * fix(tx-builder): fix pallet issues
1.7 KiB
1.7 KiB
Tenderly Simulation API
tx-builder uses Tenderly to simulate transactions before execution.
Environment Variables
VITE_TENDERLY_ORG_NAME=safe-global
VITE_TENDERLY_PROJECT_NAME=safe-apps
VITE_TENDERLY_SIMULATE_ENDPOINT_URL=https://api.tenderly.co/api/v1/account/{org}/project/{project}/simulate
Simulation Request
POST /api/v1/account/{org}/project/{project}/simulate
Request Body
interface SimulationRequest {
network_id: string // Chain ID
from: string // Safe address (sender)
to: string // Target contract
input: string // Encoded call data
value: string // Value in wei
gas: number // Gas limit
gas_price: string // Gas price
save: boolean // Save simulation to dashboard
save_if_fails: boolean // Save even if fails
simulation_type: 'quick' | 'full'
}
Response
interface SimulationResponse {
simulation: {
id: string
status: boolean // true = success
gas_used: number
method: string // Called method name
block_number: number
}
transaction: {
hash: string
transaction_info: {
call_trace: CallTrace[]
logs: Log[]
state_diff: StateDiff[]
}
}
}
interface CallTrace {
call_type: 'CALL' | 'DELEGATECALL' | 'STATICCALL'
from: string
to: string
gas: number
gas_used: number
input: string
output: string
error?: string
}
Multi-Send Simulation
For batched transactions, tx-builder encodes all transactions into a MultiSend call:
import { encodeMultiSendData } from '@safe-global/protocol-kit'
const multiSendData = encodeMultiSendData(transactions)
const simulation = await simulateTransaction({
to: MULTI_SEND_ADDRESS,
data: multiSendData,
// ...
})