Etherscan
交易從未出現在 Rinkeby
我已經用我的私鑰簽署了一筆交易,然後使用 sendRawTransaction 函式在網路上發送交易,我得到了交易雜湊,但是當我使用該交易時,在 getTransactionByHash 中我得到了空塊雜湊,響應中的塊號並且從未開採過交易。
我正在使用 web3-php 庫並在 laravel 中實現它。請幫助解決這個問題。在此先感謝您的幫助。
使用的庫: https ://github.com/web3p/web3.php https://github.com/web3p/ethereum-tx
這是我的程式碼。
$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; });
這是交易庫的問題:
https ://github.com/web3p/ethereum-tx 。請改用以下庫。
https://github.com/kornrunner/php-ethereum-offline-raw-tx
它現在對我來說很好。