GithubHelp home page GithubHelp logo

Tx Data is always null about ethereum-tx HOT 4 CLOSED

web3p avatar web3p commented on May 24, 2024
Tx Data is always null

from ethereum-tx.

Comments (4)

sc0Vu avatar sc0Vu commented on May 24, 2024

Hi @danirabbani90, would you like to post code here (please do not include sensitive information)?

from ethereum-tx.

huigan avatar huigan commented on May 24, 2024

你好,我签名后向公共节点(https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc)发起请求,可以返回交易hash,但是这个交易hash用eth_getTransactionByHash查到的信息中blockHash和blockNumber都是null,我用eth_getTransactionCount获取最新交易数,并修改了nonce,但还是这样,我的操作有哪里不对的吗?谢谢了

$transaction = new Transaction([
            'nonce' => '0xd',
            'from' => "0xF728f02b81DfE880A6CD8748893c94925d70a8B6",
            'to' => '0x68484CF447d6E2eA8AF27d2b1DfE9b8DC5d24DB3',
            'gas' => '0x1',
            'gasPrice' => '0xee6b2800',
            'value' => '0x38d7ea4c68000',
            'chainId' => 1
        ]);

        $serialize=$transaction->serialize();
        $signedTransaction = $transaction->sign("PrivateKey");
        $getFromAddress=$transaction->getFromAddress();

        $web3 = new Web3(JSONRPC_HOST);
        $eth=$web3->eth;
        $eth->sendRawTransaction('0x'.$signedTransaction, function ($err, $transaction) use ($eth) {
            if ($err !== null) {
                echo 'Error: ' . $err->getMessage();
                return;
            }
            echo 'Tx hash: ' . $transaction . PHP_EOL;
            $eth->getTransactionByHash($transaction, function ($err, $res) use ($eth) {
                if ($err !== null) {
                    var_dump($err->getMessage());
                    return;
                }
                dump($res);
                //0xcff87fe6c618a7cce954701c954a9c701d981f3b1bcab6c9e931b7fc159a9afa
            });
            //0xcff87fe6c618a7cce954701c954a9c701d981f3b1bcab6c9e931b7fc159a9afa
        });

from ethereum-tx.

huigan avatar huigan commented on May 24, 2024

你好,我签名后向公共节点(https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc)发起请求,可以返回交易hash,但是这个交易hash用eth_getTransactionByHash查到的信息中blockHash和blockNumber都是null,我用eth_getTransactionCount获取最新交易数,并修改了nonce,但还是这样,我的操作有哪里不对的吗?谢谢了

$transaction = new Transaction([
            'nonce' => '0xd',
            'from' => "0xF728f02b81DfE880A6CD8748893c94925d70a8B6",
            'to' => '0x68484CF447d6E2eA8AF27d2b1DfE9b8DC5d24DB3',
            'gas' => '0x1',
            'gasPrice' => '0xee6b2800',
            'value' => '0x38d7ea4c68000',
            'chainId' => 1
        ]);

        $serialize=$transaction->serialize();
        $signedTransaction = $transaction->sign("PrivateKey");
        $getFromAddress=$transaction->getFromAddress();

        $web3 = new Web3(JSONRPC_HOST);
        $eth=$web3->eth;
        $eth->sendRawTransaction('0x'.$signedTransaction, function ($err, $transaction) use ($eth) {
            if ($err !== null) {
                echo 'Error: ' . $err->getMessage();
                return;
            }
            echo 'Tx hash: ' . $transaction . PHP_EOL;
            $eth->getTransactionByHash($transaction, function ($err, $res) use ($eth) {
                if ($err !== null) {
                    var_dump($err->getMessage());
                    return;
                }
                dump($res);
                //0xcff87fe6c618a7cce954701c954a9c701d981f3b1bcab6c9e931b7fc159a9afa
            });
            //0xcff87fe6c618a7cce954701c954a9c701d981f3b1bcab6c9e931b7fc159a9afa
        });

换了一个公共节点,就可以了,之前用的nodesmith.io,改成infura.io的就可以了

from ethereum-tx.

sc0Vu avatar sc0Vu commented on May 24, 2024

@huigan because your transaction wasn't included in the block, you got the null when search the transaction hash. You might need to check the gas or gasPrice.

from ethereum-tx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.