src/Transaction.php
public function sign(string $privateKey)
    {
        $txHash = $this->hash(false);
        $privateKey = $this->secp256k1->keyFromPrivate($privateKey, 'hex');
        $signature = $privateKey->sign($txHash, [
            'canonical' => true
        ]);
        $r = $signature->r;
        $s = $signature->s;
        $v = $signature->recoveryParam + 35;

        $chainId = $this->offsetGet('chainId');

        if ($chainId && $chainId > 0) {
            $v += (int) $chainId * 2;
        }

        $this->offsetSet('r', '0x' . $r->toString(16));
        $this->offsetSet('s', '0x' . $s->toString(16));
        $this->offsetSet('v', $v);
        $this->privateKey = $privateKey;

        return $this->serialize()->toString('hex');
    }
public function sign(string $privateKey)
    {
        $txHash = $this->hash(false);
        $privateKey = $this->secp256k1->keyFromPrivate($privateKey, 'hex');
        $signature = $privateKey->sign($txHash, [
            'canonical' => true
        ]);
        $r = $signature->r;
        $s = $signature->s;
        $v = $signature->recoveryParam + 35;

        $chainId = $this->offsetGet('chainId');

        if ($chainId && $chainId > 0) {
            $v += (int) $chainId * 2;
        }

        $this->offsetSet('r', '0x' . $r->toString(16));
        $this->offsetSet('s', '0x' . $s->toString(16));
        $this->offsetSet('v', $v);
        $this->privateKey = $privateKey;

        return $this->serialize()->toString('hex');
    }
sign

@param string $privateKey
@return string