1

How do you use Web3 in Google App Script? So far I managed to view the Web3 Library code in the console using this:

var Web3 = UrlFetchApp.fetch("https://cdnjs.cloudflare.com/ajax/libs/web3/3.0.0-rc.5/web3.min.js").getContentText();
Logger.log(Web3)

However when I try to create a new object using var web3 = new Web3({parameters}), it gives a type error stating Web3 isn't a constructor. Also when I try to use eval("var x = "+Web3) it gives

Reference Error: window is not defined.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Sarad
  • 11
  • 1
  • Try putting this in the head: `` – Cooper Jul 15 '21 at 18:29
  • https://stackoverflow.com/questions/65802366/metamask-does-not-inject-window-ethereum-uncaught-in-promise-typeerror-canno – Cooper Jul 15 '21 at 18:35
  • Tl;Dr Google Apps Script runtime executes code on the server, so there aren't objects from web APIs like `window`, `document` etc. – Rubén Nov 08 '22 at 22:20

0 Answers0