export class TenderlySimulationSigner {
public _provider: ethers.Provider;
provider: ethers.Provider,
this._provider = provider;
public async sendTransaction(
transaction: Deferrable<TransactionRequest>
): Promise<TransactionResponse> {
await this._simulateTx(transaction)
return this._signer.sendTransaction(transaction);
public async getAddress(): Promise<string> {
return this._signer.getAddress();
public async signTransaction(
transaction: Deferrable<TransactionRequest>
return this._signer.signTransaction(transaction);
_simulateTx(transaction: Deferrable<TransactionRequest>): Promise<void> {
const unsignedTx = await contract.populateTransaction[funcName](...args)
const apiURL = `https://api.tenderly.co/api/v1/account/me/project/project/simulate`
"input": unsignedTx.data,
'content-type': 'application/JSON',
'X-Access-Key': REACT_APP_TENDERLY_ACCESS_KEY as string,
const resp = await axios.post(apiURL, body, headers);
if (resp.data.simulation.status == false) {
throw new Error("Transaction is going to fail")