Returns the information about a transaction requested by transaction hash or number. In the response object, blockHash
, blockNumber
, and transactionIndex
are null
when the transaction is pending.
const { calls, logs, error } = await alchemy.transact.simulateExecution(transaction);
Full example
// npm install alchemy-sdk
// Github: https://github.com/alchemyplatform/alchemy-sdk-js
import { Network, Alchemy } from "alchemy-sdk";
// Optional config object, but defaults to demo api-key and eth-mainnet.
const settings = {
apiKey: "demo", // Replace with your Alchemy API Key.
network: Network.ETH_MAINNET, // Replace with your network.
};
const alchemy = new Alchemy(settings);
(async => {
const transaction = {
from: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
value: '0x0',
data: '0xa9059cbb000000000000000000000000fc43f5f9dd45258b3aff31bdbe6561d97e8b71de00000000000000000000000000000000000000000000000000000000000f4240'
};
const { calls, logs, error } = await alchemy.transact.simulateExecution(transaction);
console.log('Calls', calls);
console.log('Logs', logs);
console.log('Error', error);
})();