Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Failed to query "transaction sent by MetaMask" through transaction hash #630

Closed
summerpro opened this issue Dec 4, 2020 · 4 comments · Fixed by #683
Closed

Failed to query "transaction sent by MetaMask" through transaction hash #630

summerpro opened this issue Dec 4, 2020 · 4 comments · Fixed by #683

Comments

@summerpro
Copy link
Contributor

summerpro commented Dec 4, 2020

System info: [Include Ethermint commit, operating system name, and other relevant details]

Steps to reproduce:

  1. Start a single node locally through init.sh

  2. Send a transaction through MetaMask, such as deploying a contract

  • Get transaction hash from the remix return result
    image
  1. Query method one: Query transactions through rest api interface /txs/{hash}
http://localhost:8545/txs/58a96e35de19b26bc3728e02a3186a86ec86930aa237c12f66a6594a314d64fd
  • The results are as follows:
{"error":"UnmarshalBinaryBare expected to read prefix bytes 282816A9 (since it is registered concrete) but got 25A6BE54..."}
  1. Query method two: Query through the jsonrpc interface
curl  -H "Content-Type:application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0x58a96e35de19b26bc3728e02a3186a86ec86930aa237c12f66a6594a314d64fd
"],"id":1}' -H "Content-Type: application/json"  localhost:8545
  • The results are as follows:
{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"parse error"}}

Additional info: [Include gist of relevant config, logs, etc.]

  • It may be that cosmos-style transaction types are used to parse eth-style transactions, and the format analysis fails
@summerpro summerpro changed the title Query "transaction information sent by MetaMask" through transaction hash, the query fails Failed to query "transaction sent by MetaMask" through transaction hash Dec 4, 2020
@araskachoi
Copy link
Contributor

Hello @summerpro , thank you for bringing this issue up! I am looking into why 3. is not working. however, I was unable to reproduce 4. Would it be possible for you to try again and see if 4. is still an issue? And if so, could you provide us with some steps to reproduce the parse error? Thank you!

@summerpro
Copy link
Contributor Author

Hi, @araskacho , it's my pleasurei.I just tried it, and step 4 will still a problem.Let me write the detailed reproduction steps:

1. start node

  • checkout branch development
  • start ethermintd
./init.sh
  • start rest server:
ethermintcli rest-server --laddr "tcp://localhost:8545" --unlock-key mykey --chain-id ethermint-1 --trace

2. Connect to ethermint node with metaMask

image

image

3. deploy a contract with remix

  • The sample contract is at the bottom

image

image

4. query

 curl  -H "Content-Type:application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xa87111e732f7e77224acb333cea9ab7f517022e65888555243a91ec11bde8090
quote> "],"id":1}' -H "Content-Type: application/json"  localhost:8545

image

5. code

  • sample contract:
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.8.0;

/**
 * @title Owner
 * @dev Set & change owner
 */
contract Owner {

    address private owner;
    
    // event for EVM logging
    event OwnerSet(address indexed oldOwner, address indexed newOwner);
    
    // modifier to check if caller is owner
    modifier isOwner() {
        // If the first argument of 'require' evaluates to 'false', execution terminates and all
        // changes to the state and to Ether balances are reverted.
        // This used to consume all gas in old EVM versions, but not anymore.
        // It is often a good idea to use 'require' to check if functions are called correctly.
        // As a second argument, you can also provide an explanation about what went wrong.
        require(msg.sender == owner, "Caller is not owner");
        _;
    }
    
    /**
     * @dev Set contract deployer as owner
     */
    constructor() {
        owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
        emit OwnerSet(address(0), owner);
    }

    /**
     * @dev Change owner
     * @param newOwner address of new owner
     */
    function changeOwner(address newOwner) public isOwner {
        emit OwnerSet(owner, newOwner);
        owner = newOwner;
    }

    /**
     * @dev Return owner address 
     * @return address of owner
     */
    function getOwner() external view returns (address) {
        return owner;
    }
}

@araskachoi
Copy link
Contributor

hello @summerpro , for 4. it looks like your request is malformed.. after the hash, i see that there is quote> included at the end of the string. I belive that is the reason why you are getting a parse error there. The RPC cmd for getTrasnactionByHash should be behaving as intended but we are still investigating where the issue is arising for querying the endpoint http://localhost:8545/txs/<txhash>.

We apologize for the inconvenience and we will work hard to rectify this as soon as possible! Thank you for your time and patience

@summerpro
Copy link
Contributor Author

@araskachoi Oh, I get it, thank you very much.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants