Enviar transações assinadas para a Ropsten ou Truffle desenvolver rede com Trezor (Hardware Wallet)

Estou tentando integrarweb3js comTrezor em umBrigadeiro rede dev ou usandorede de teste de ropsten.

A idéia é assinar as transações usando ocarteira de hardware e, em seguida, envie uma transação bruta usando web3js

Estou percebendo que não temos saldo para fazer a transação,provavelmente porque o web3js não está usando uma das 10 contas de trufas e está usando o endereço trezor que não está na minha rede local..

No ropsten, tenho alguns éteres e recebo "endereço inválido"

Existe uma maneira de enviar transações assinadas (com trezor) usando web3js em uma rede de desenvolvimento de trufas? Quero dizer, existe uma maneira de incluir o endereço trezor na rede de trufas?

A situação na trufa é explicada mais em detalhes aqui, mas a questão pode ser generalizada para "existe uma maneira de incluir carteiras de hardware na rede de desenvolvimento de trufas?":https://github.com/trufflesuite/truffle/issues/973

Usando ropsten, eu consegui enviar uma transação e receber um hash de transação no retorno de chamada, mas se consultarmos essa transação, obteremos que a transação não existe .. então ... como isso é possível?

Tentei implantar um contrato no Ropsten também e agora estou recebendo "Endereço inválido" ao invocar uma função de contrato inteligente. Talvez a função de assinatura esteja errada? alguém poderia integrar a assinatura da transação Trezor com o web3js?

Vocês vêem algo errado no processo de assinatura e envio que seguimos? Talvez haja algo errado na manipulação dos parâmetros R, V e S ..

Outra coisa importante é que eu estou usandohttps://github.com/ethereumjs/ethereumjs-tx para criar as transações brutas

Os problemas publicados no web3js, trufa e trezzor se conectam com mais informações:

https://github.com/trufflesuite/truffle/issues/973https://github.com/ethereum/web3.js/issues/1669https://github.com/trezor/connect/issues/130

Atenciosamente

 trezorLogin = async()=> {
        let trezor=  await this.getTrezor();

        // site icon, optional. at least 48x48px
        var hosticon = 'https://doc.satoshilabs.com/trezor-apps/_images/copay_logo.png';
        // server-side generated and randomized challenges
        var challenge_hidden = '';
        var challenge_visual = '';
        //use anonimous functions on callback otherwise returns cross origin errors
        trezor.requestLogin(hosticon, challenge_hidden, challenge_visual, function (result){
            if (result.success) {
                console.log('Public key:', result.public_key); // pubkey in hex
                console.log('Signature:', result.signature); // signature in hex
                console.log('Version 2:', result.version === 2); // version field
                console.log(result);
            }else {
                console.error('Error:', result.error);
            }
        });}


    trezorSignTx= async(transaction)=> {
        let trezor=  await this.getTrezor();
        // spend one change output
        var address_n = "m/44'/60'/0'/0/0"
        // var address_n = [44 | 0x80000000,
        //                  60 | 0x80000000,
        //                  0  | 0x80000000 ,
        //                  0 ]; // same, in raw form
        var nonce = transaction.nonce.substring(2); // note - it is hex, not number!!!
        var gas_price = transaction.gasPrice.substring(2);
        var gas_limit = transaction.gasLimit.substring(2);
        var to = transaction.to.substring(2);
        // var value = '01'; // in hexadecimal, in wei - this is 1 wei
        var value = transaction.value.substring(2); // in hexadecimal, in wei - this is about 18 ETC
        var data = transaction.data.substring(2); // some contract data
        // var data = null  // for no data
        var chain_id = 5777; // 1 for ETH, 61 for ETC
        return new Promise (function (resolve,reject) {
            trezor.ethereumSignTx(
                address_n,
                nonce,
                gas_price,
                gas_limit,
                to,
                value,
                data,
                chain_id,
                function (response) {
                    if (response.success) {

                        console.log('Signature V (recovery parameter):', response.v); // number
                        console.log('Signature R component:', response.r); // bytes
                        console.log('Signature S component:', response.s); // bytes
                        resolve(response);

                    } else {
                        console.error('Error:', response.error); // error message
                        resolve(null);
                    }

                });
        })
    }

    getTrezorAddress = async() => {
        let trezor=  await this.getTrezor();
        // spend one change output
        var address_n = "m/44'/60'/0'/0/0";
        trezor.ethereumGetAddress(address_n, function (result) {
            if (result.success) { // success
                console.log('Address: ', result.address);
            } else {
                console.error('Error:', result.error); // error message
            }
        });
    }


    getTrezor = async() => {
        let trezorC;
        await getTrezorConnect
            .then(trezorConnect => {
                trezorC= trezorConnect;
            })
            .catch((error) => {
                console.log(error)
            })
        return trezorC;

    }

 sendTransaction= async(address, amount, id)=>{
        let tokenInstance = this.props.smartContractInstance;

        var getData = tokenInstance.mint.getData(address, amount);

        var tx = {
            nonce: '0x00',
          ,  gasPrice: '0x09184e72a000',
            gasLimit: '0x2710',
            to: CONTRACT_ADDRESS,
            value: '0x00',
            from:CONTRACT_OWNER_ADDRESS,
            data: getData
        };
        let response = await this.trezorSignTx(tx);

        let web3;
        let _this = this;
        if (response!=null){
            getWeb3
                .then(results => {
                    web3= results.web3;
                    let v = response.v.toString();
                    if (v.length % 2 != 0){
                        v="0"+v;
                    }
                    tx.r=Buffer.from(response.r,'hex');
                    tx.v=Buffer.from(v,'hex');
                    tx.s=Buffer.from(response.s,'hex');
                    let ethtx = new ethereumjs(tx);
                    console.dir(ethtx.getSenderAddress().toString('hex'), );
                    const serializedTx = ethtx.serialize();
                    const rawTx = '0x' + serializedTx.toString('hex');
                    console.log(rawTx);
                    //finally pass this data parameter to send Transaction
                    web3.eth.sendRawTransaction(rawTx, function (error, result) {
                        if(!error){
                            _this.props.addTokens(id)
                                .then(()=>{
                                        _this.setState({modalOpen: true});
                                        _this.props.getAllTransactions();
                                    }
                                );
                        }else{
                            alert(error)
                        }
                    });
                })
                .catch((error) => {
                    console.log(error)
                })
        }else{
            alert("There was an error signing with trezor hardware wallet")
        }


    }

A função getTrezorConnect é apenas obter window.trezorConnect de forma assíncrona porque o objeto é injetado como script

<script src="https://connect.trezor.io/4/connect.js"></script>


let getTrezorConnect = new Promise(function(resolve, reject) {
    // Wait for loading completion
    window.addEventListener('load', function() {

        var trezorConnect = window.TrezorConnect

            return resolve(trezorConnect)


})});

export default getTrezorConnect

questionAnswers(1)

yourAnswerToTheQuestion