generar trx sin procesar y enviarlo a la red muestra el error "remitente no válido"

Estoy tratando de hacer una transacción sin procesar de ethereum por php y estas bibliotecas:

https://github.com/simplito/elliptic-php

https://github.com/kornrunner/php-keccak

https://github.com/web3p/rlp

este es mi código:

use Elliptic\EC;
use kornrunner\Keccak;
use Web3p\RLP\RLP;

$privateKeyHex = '.....'; // wallet private key
$toWallet = '118086be6247fBDa3BC64B4A11F07F3894aA1fAF';

$ec = new EC('secp256k1');
$key = $ec->keyFromPrivate($privateKeyHex );
$publicKeyHex = $key->getPublic('hex');
// $publicKeyHex => 0445e2caf0f227247dfa10440765812492e4d4c9df7b4e74d0d5cd3279fa80f5ef987a70e061ca20c06f09690957c9ba365cf06541181d1291e14c847d0d826583

$nonce= 0;
$gasPrice = 1e10;
$gasLimit = 21000;
$to = hex2bin($toWallet);
$value = 1e15-($gasLimit*$gasPrice)-1;
$inputData = 0;
//*********** EIP_155 *********
$chain_id = 1;
$r = 0;
$s = 0;
//*****************************

$SignData = [$nonce,$gasPrice,$gasLimit,$to,$value,$inputData,$chain_id,$r,$s];
$SignRlpData = rlpEncode($SignData);
$signHash = Keccak::hash(hex2bin($SignRlpData), 256);

$signature = $ec->sign($signHash ,$key);
$r = $signature->r->toString('hex');
$s = $signature->s->toString('hex');
$v = $chain_id*2 + ($signature->recoveryParam +35);

$trxData = [$nonce,$gasPrice,$gasLimit,$to,$value,$inputData,$v,hex2bin($r),hex2bin($s)];
$trxRlpData = rlpEncode($trxData );
// trxRlpData => f86b808502540be40082520894118086be6247fbda3bc64b4a11f07f3894aa1faf8702ce80355f5fff8026a0d879bd4319788f5e75fba039f879f7b38f25a80d1b6768f8c80d2e0dec7dc11aa0d952e26360e25f95821fc7f92d231925cd0cd1c412fc1d4b5bbdb439fbf0f19b




function rlpEncode($a){
    $rlp = new RLP;
    $encodedBuffer = $rlp->encode($a);
    return $encodedBuffer->toString('hex');
}

ahora, después de enviar valor $trxRlpDataa la red ethereum por https://etherscan.io/pushTx , muéstrame este mensaje de error:

Error! Unable to broadcast Tx : {"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"invalid sender"}}

pero donde esta el problema

Respuestas (1)

finalmente descubrí que el problema se debía a valores incorrectos para las variables $gasPrice , $gasLimit y $value .

Después de hacer estos cambios, el problema actual se ha solucionado:

$gasPrice = 1e9;
$value = 1e14-($gasLimit*$gasPrice);

Pero me encontré con otro error llamado transacción subvaluada . finalmente resolví este problema aumentando un poco $gasLimit .

$gasLimit = 21001;