I'm trying to get the balance of an account with this code (dfuse example):

global.fetch = require("node-fetch");
global.WebSocket = require("ws");

const { createDfuseClient } = require("@dfuse/client")
const client = createDfuseClient({ 
  apiKey: "myKey", network: "mainnet" 

const resp = await client.stateTable("eosio.token", "myaccount", "accounts")
const { balance } = resp.rows[0].json
const message = `Balance: ${balance} (#${resp.up_to_block_num})`

However, I need to specify a proxy agent to connect to the endpoint, since I go via a proxy server. Anybody knows how to do this?



I found a way, not sure if there is a better one.

In http-client.js inside request() I add directly the proxy agent:

let HttpsProxyAgent = require ('https-proxy-agent')
let proxy = 'http://X.X.X.X:PPPP'  // My proxy IP:Port
let agent_proxy = new HttpsProxyAgent (proxy)

const response = yield this.fetch(url, {
         headers: mergedHeaders,
         body: transformedBody,
         agent: agent_proxy

Now it connects.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.