scatter-js icon indicating copy to clipboard operation
scatter-js copied to clipboard

Blocking when sendTransaction in Tron

Open AnyPang opened this issue 4 years ago • 1 comments

I copy the quick code of the tronweb part in README file and change the network config to tron shasta testnet, then I run it in nodejs. I success login and get the account from the Scatter wallet, but it seems block when call the sendTransaction and print nothing in the console. Dose it support the Shasta testnet? My code is as follows:

import ScatterJS from '@scatterjs/core';
import ScatterTron from '@scatterjs/tron';
import TronWeb from 'tronweb';

ScatterJS.plugins( new ScatterTron() );

const network = ScatterJS.Network.fromJson({
    blockchain:'trx',
    chainId:'1',
    host:'api.shasta.trongrid.io',
    port:443,
    protocol:'https'
});

const httpProvider = new TronWeb.providers.HttpProvider(network.fullhost());
let tron = new TronWeb(httpProvider, httpProvider, network.fullhost());
tron.setDefaultBlock('latest');

ScatterJS.connect('YourAppName', {network}).then(connected => {
    if(!connected) return console.error('no scatter');

    tron = ScatterJS.trx(network, tron);

    ScatterJS.login().then(id => {
        if(!id) return console.error('no identity');
        const account = ScatterJS.account('trx');
        console.log(account);
        tron.trx.sendTransaction('TFwwmGs5YrP9NR7w9RSdxVPGPFrN7jNF6n', 100).then(res => {
            console.log('sent: ', res);
        }).catch(err => {
            console.error('error: ', err);
        });
    });
});

AnyPang avatar Apr 08 '20 03:04 AnyPang

It also has the same problem in the Tron mainnet

AnyPang avatar Apr 08 '20 06:04 AnyPang