tl,dr: Remix shows a formatted transaction summary for transactions that are initiated within the Remix IDE. Is it possible to display the same output for an arbitrary transaction hash?

Sorry if this is a noob question... but I'm a complete noob working through the Mastering Ethereum book examples now.

Using MetaMask as my Web3 injector, I've deployed the faucet contract at the bottom of this post to Ropsten using the Remix IDE. When I call the withdraw() function from the Remix IDE, I sign the transaction in MetaMask... and after a short while I get a nice formatted summary of the transaction:

status                  true Transaction mined and execution succeed
transaction hash        0x84f351c3dfd89ed28ce71afc8f5e87ca2e5d103d3a6a1a61dc00c0337f59c7cf 
from                    0x3661332E7c6a0CdEDAe68D43BD4a3866E166724d 
to                      Faucet.withdraw(uint256) 0xb8eB093f6D59B1a6a7AeF546CB6E3b7Dda301F2E 
gas                     31256 gas 
transaction cost        30453 gas 
hash                    0x84f351c3dfd89ed28ce71afc8f5e87ca2e5d103d3a6a1a61dc00c0337f59c7cf 
input                   0x2e1...51000 
decoded input           { "uint256 withdraw_amount": { "_hex": "0xe8d4a51000" } } 
decoded output          - 
logs                    [ { "from": "0xb8eB093f6D59B1a6a7AeF546CB6E3b7Dda301F2E", "topic": "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65", "event": "Withdrawal", "args": { "0": "0x3661332E7c6a0CdEDAe68D43BD4a3866E166724d", "1": "1000000000000", "to": "0x3661332E7c6a0CdEDAe68D43BD4a3866E166724d", "amount": "1000000000000", "length": 2 } } ]  
value                   0 wei

While it's not the most beautiful looking output, it is crystal clear that I have coded the events properly (part of this example) because I can easily verify that the logs have captured the address that I used to call the function as well as the amount of wei withdrawn.

However, in order to deposit Ether into the faucet I'm using the receive fallback function (which I don't have an option to access directly from the Remix IDE) by initiating a send transaction from within MetaMask. Is it possible to display a nice formatted transaction summary in Remix for an arbitrary transaction hash? I have tried using the web3 API but the output is ugly, and also does not seem to decode the event logs either (which is ultimately what I'm trying to see as part of this example):

> web3.eth.getTransactionReceipt("0x04d2a7afff4dc6b91c8a9177b8ad4bdd0e1807c0d2b23ac8dac0d7c9fa0b79cf").then(console.log)

{ "blockHash": "0x2d8487517c2f0c6dcfb02507a0fa3ac55f5d3a7dd19219ec0afff238c5bab1b7", "blockNumber": 8490972, "contractAddress": null, "cumulativeGasUsed": 67479, "from": "0x3661332e7c6a0cdedae68d43bd4a3866e166724d", "gasUsed": 22504, "logs": [ { "address": "0xb8eB093f6D59B1a6a7AeF546CB6E3b7Dda301F2E", "blockHash": "0x2d8487517c2f0c6dcfb02507a0fa3ac55f5d3a7dd19219ec0afff238c5bab1b7", "blockNumber": 8490972, "data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "logIndex": 2, "removed": false, "topics": [ "0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c", "0x0000000000000000000000003661332e7c6a0cdedae68d43bd4a3866e166724d" ], "transactionHash": "0x04d2a7afff4dc6b91c8a9177b8ad4bdd0e1807c0d2b23ac8dac0d7c9fa0b79cf", "transactionIndex": 1, "id": "log_a4c6ccbb" } ], "logsBloom": "0x02000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000040000002104000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000", "status": true, "to": "0xb8eb093f6d59b1a6a7aef546cb6e3b7dda301f2e", "transactionHash": "0x04d2a7afff4dc6b91c8a9177b8ad4bdd0e1807c0d2b23ac8dac0d7c9fa0b79cf", "transactionIndex": 1 }

As an alternative to being able to display an arbitrary transaction summary nicely, would it be possible to use the 'Low level interactions' tool in the Remix IDE to deposit ether with the receive fallback function? I imagine this would then trigger the formatted transaction summary that appears when other transactions are initiated within the Remix IDE.

Thanks for your help :)

Contract code:

// Version of Solidity compiler this program was written for
pragma solidity ^0.6.6;

// Our first contract is a faucet!

contract owned {

    // Variables

    address payable owner;                                      // Address that speifies the contract's administrator, and that it can receive funds.

    // Methods

    // Contract constructor: set owner
    constructor() public {                                      // A constructor function is only called when the contract is created. It initializes the state of the contract.
        owner = msg.sender;                                     // The contract creator is specified as the administrator of the contract

    // Access control modifier
    modifier onlyOwner {                                        // Function modifiers create conditions that can apply to arbitrary functions; this one makes them usable by only the administrator.
        require(msg.sender == owner, "Only the contract owner can call this function");     // Require can provide text that is added to the transaction log if execution is stopped.
        _;                                                      // The modified function(s) code is executed here.

contract mortal is owned {                                      // The mortal contract (child) inherits all methods, functionality and variables from the owned contract (parent).

    // Methods

    //contract destructor
    function destroy() public onlyOwner {                       // public means destroy can be called from outside the contract. The inherited onlyOwner modifier means only the admin will succeed.
        selfdestruct(owner);                                    // selfdestruct deletes contract from existance and sends funds in the contract to specified address (inherited admin address here).

contract Faucet is mortal {                                     // Faucet contract inherits the destructor function in mortal, and by extension the constructor function and admin adress from owned.

    // Events - high-level solidity objects used to construct the log entries contained in a tranaction receipt. They provide information about the events that occurred in executing the transaction.

    event Withdrawal(address indexed to, uint amount);          // When a Withdrawal event is emitted, save the amount of funds withdrawn, and the address they are withdrawn to (searchable by to).
    event Deposit(address indexed from, uint amount);           // When a Deposit event is emitted, save the amount of funds deposited, and the address they are deposited from (searchable by from).

    // Methods

    // Give out ether to anyone who asks

    function withdraw(uint withdraw_amount) public {            // The public declaration means anyone can withdraw funds.
        // Limit withdrawal withdraw_amount
        require(withdraw_amount <= 0.1 ether);
        require(address(this).balance >= withdraw_amount, "Insufficient balance in faucet for withrawal request");
        // Send the ammount to the address that requested It
        emit Withdrawal(msg.sender, withdraw_amount);           // Incorporate the withdrawal event data in the transaction logs.

    // Accept any incoming ether

    receive () external payable {
        emit Deposit(msg.sender, msg.value);                    // Incorporate the deposit event data in the transaction logs.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.