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.

3
  • Try putting this in the head: <script src="https://cdnjs.cloudflare.com/ajax/libs/web3/3.0.0-rc.5/web3.min.js"></script> Commented Jul 15, 2021 at 18:29
  • stackoverflow.com/questions/65802366/… Commented Jul 15, 2021 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. Commented Nov 8, 2022 at 22:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.