1

UPDATED: I am trying to download source code of open source verified contract from Etherscan.io. Here is my procedure as directed by Ann. 1. Download CSV file of captioned contracts. 2. Write following program to print source code of contract

const fs = require('fs-extra');
const csv = require('fast-csv')
const jsdom = require("jsdom");
const { window } = new jsdom.JSDOM(`...`);
var $ = require("jquery")(window);


var addresses = [];

fs.createReadStream('./osContracts/list.csv')
.pipe(csv.parse({ headers: true }))
.on('data', (data) => addresses.push(data))
.on('end', () => {
  console.log("There are address: ", addresses.length)
  for(i=0; i<addresses.length; i++){
    $.getJSON('https://api.etherscan.io/api?module=contract&action=getsourcecode&address='+addresses[i]+'&apikey=454BC5UXKPI2.............', function (adData) {
      console.log(adData)           
  });
  }
});

Here is my output

Error: Cross origin null forbidden
    at dispatchError (C:\Users\aa\Desktop\temp\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:54:19)
    at Object.validCORSHeaders (C:\Users\aa\Desktop\temp\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:66:5)
    at receiveResponse (C:\Users\aa\Desktop\temp\node_modules\jsdom\lib\jsdom\living\xmlhttprequest.js:843:21)
    at Request.<anonymous> (C:\Users\aa\Desktop\temp\node_modules\jsdom\lib\jsdom\living\xmlhttprequest.js:678:38)
    at Request.emit (events.js:210:5)
    at Request.onRequestResponse (C:\Users\aa\Desktop\temp\node_modules\request\request.js:1066:10)
    at ClientRequest.emit (events.js:210:5)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:583:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:115:17)
    at TLSSocket.socketOnData (_http_client.js:456:22)
    at TLSSocket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23) undefined
Error: Cross origin null forbidden
    at dispatchError (C:\Users\aa\Desktop\temp\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:54:19)
    at ...........................................

UPDATE: also when i setTimout then following errors are also showing alongwith the previous ones...

{ status: '0', message: 'NOTOK', result: 'Invalid Address format' }
  • I'd recommend consolidating this into your original question, otherwise moderators might think it's a duplicate. You can edit the original post and put an UPDATE heading over it. – Ann Kilzer Dec 3 '19 at 3:09
  • sorry, what "THIS" .... you are referring ?? .. means the last one ? – Amir Ali Dec 3 '19 at 3:19
  • I am referring to this question. I think it's unlikely to get answered broken out from your original issue. – Ann Kilzer Dec 3 '19 at 12:42
  • so should i post afresh with same data ? – Amir Ali Dec 4 '19 at 1:48
  • Just update your original post. – Ann Kilzer Dec 4 '19 at 5:27

Your Answer

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

Browse other questions tagged or ask your own question.