首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >事务从未出现在Rinkeby上

事务从未出现在Rinkeby上
EN

Ethereum用户
提问于 2021-11-25 04:53:56
回答 1查看 130关注 0票数 1

我用我的私钥签署了一个事务,然后使用sendRawTransaction函数在网络上发送事务,我得到了事务哈希,但是当我在getTransactionByHash中使用这个事务时,我得到了空块哈希、响应中的块号和从未挖掘的事务。

我正在使用web3-php库并在laravel中实现它。请帮助解决这个问题。提前谢谢你的帮助。

使用的库:https://github.com/web3p/web3.php https://github.com/web3p/ethereum-tx

这是我的密码。

代码语言:javascript
复制
                $toAddress      = '0x551f7DaFb0569....';
                $fromAccount    = $this->getOwnerAddress();
                
                $from_addr_nonce = "";
                $contract       = $this->getDeployedContract();
                $eth            = $this->getEthObject();
                $eth->getTransactionCount($this->getOwnerAddress(),function($err,$data) use (&$from_addr_nonce){
                    $from_addr_nonce = gmp_intval($data->value);
                });
                $from_addr_nonce = Utils::toHex($from_addr_nonce,true);
                $data     =  "0x".$contract->getData('safeMint', $toAddress, $metadataHash);

                $gasPrice = Utils::toHex(1000);
                $gas      = 10e6;

                $txParams = [
                    'from'      => $fromAccount,
                    'to'        => $this->contractAddress,
                    'value'     => "0x0",
                    'nonce'     => $from_addr_nonce,
                    'gas'       => Utils::toHex($gas,true),
                    'gasPrice'  => $gasPrice,
                    'chainId'   => 4,
                    'data'      => $data,
                ];

                $transaction        = new Transaction($txParams);

                $signedTransaction  = $transaction->sign($this->getprivateKey());

                $eth->sendRawTransaction("0x".$signedTransaction, function ($err, $tx) use (&$nftAddress) {
                    if ($err !== null) {
                        echo "Error: ".$err->getMessage();
                        exit();
                    }
                    $nftAddress = $tx;
                });
EN

回答 1

Ethereum用户

回答已采纳

发布于 2021-11-26 09:30:58

这是事务库的一个问题:https://github.com/web3p/ethereum-tx。改为使用以下库。https://github.com/kornrunner/php-ethereum-offline-raw-tx

我现在很好用。

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/114265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档