How to use the tronweb.providers function in tronweb

To help you get started, we’ve selected a few tronweb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tronscan / tronscan-frontend / src / services / api.js View on Github external
import { Client as ApiClient } from "@tronscan/client";
import io from "socket.io-client";
import TronWeb from "tronweb";
import xhr from "axios/index";
import { API_URL } from "../constants.js";
import { setLoginWithAddress } from "../actions/app.js";

const ServerNode = "https://api.trongrid.io";
const HttpProvider = TronWeb.providers.HttpProvider; // This provider is optional, you can just use a url for the nodes instead
const fullNode = new HttpProvider(ServerNode); // Full node http endpoint
const solidityNode = new HttpProvider(ServerNode); // Solidity node http endpoint
const eventServer = ServerNode; // Contract events http endpoint
export const tronWeb = new TronWeb(fullNode, solidityNode, eventServer);

export const Client = new ApiClient(API_URL);

export function buildClient(account) {
  return new ApiClient(API_URL);
}

export function channel(path, options) {
  // return io(process.env.API_URL + path, options);
  return io("https://wlcyapi.tronscan.org/socket.io" + path, options);
  //return io('http://172.16.20.207:20110/socket.io' + path, options);
}
github tronscan / tronscan-frontend / src / reducers / app.js View on Github external
isLoggedIn: true,
          address: passwordToAddress(action.password)
        },
        wallet: {
          type: ACCOUNT_PRIVATE_KEY,
          address: passwordToAddress(action.password),
          isOpen: true,
        },
      };
    }

    case LOGIN_PK: {

       Lockr.set("islogin", 0);
       const ServerNode =  SUNWEBCONFIG.MAINFULLNODE;
       const HttpProvider = TronWeb.providers.HttpProvider; // This provider is optional, you can just use a url for the nodes instead
       const fullNode = new HttpProvider(ServerNode); // Full node http endpoint
       const solidityNode = new HttpProvider(ServerNode); // Solidity node http endpoint
       const eventServer = ServerNode; // Contract events http endpoint
       const privateKey = action.privateKey;
       const tronWeb = new TronWeb({
               fullNode,
               solidityNode,
               eventServer,
               privateKey
          }
       );
       const sunWeb = new SunWeb(
          {
              fullNode: ServerNode,
              solidityNode: ServerNode,
              eventServer: ServerNode,
github GetScatter / ScatterDesktop / src / plugins / defaults / trx.js View on Github external
init(){
	    const DUMMY_NET = 'https://api.shasta.trongrid.io'
	    const provider = new TronWeb.providers.HttpProvider(DUMMY_NET);
	    const tronWeb = new TronWeb(provider, provider, DUMMY_NET);
	    utils = tronWeb.utils;
    }
github TronLink / tronlink-extension / packages / pageHook / handlers / ProxiedProvider.js View on Github external
import TronWeb from 'tronweb';
import Logger from '@tronlink/lib/logger';
import axios from 'axios';

const { HttpProvider } = TronWeb.providers;
const logger = new Logger('ProxiedProvider');

class ProxiedProvider extends HttpProvider {
    constructor() {
        super('http://127.0.0.1');

        logger.info('Provider initialised');

        this.ready = false;
        this.queue = [];
    }

    configure(url) {
        logger.info('Received new node:', url);

        this.host = url;
github TronLink / tronlink-extension / packages / pageHook / handlers / ProxiedProvider.js View on Github external
import TronWeb from 'tronweb';
import Logger from '@tronlink/lib/logger';
import axios from 'axios';

const { HttpProvider } = TronWeb.providers;
const logger = new Logger('ProxiedProvider');

class ProxiedProvider extends HttpProvider {
    constructor(chainType = 0) {
        super('http://127.0.0.1');

        logger.info('Provider initialised');

        this.ready = false;
        this.queue = [];
        this.chainType = chainType;
    }

    configure(url) {
        logger.info('Received new node:', url);

tronweb

JavaScript SDK that encapsulates the TRON HTTP API

MIT
Latest version published 3 months ago

Package Health Score

84 / 100
Full package analysis