-1

I have a json file that's an ABI for a smart contract. I am building a site in Webflow, but due to the 10000 character custom code limit, I need to host the json for the smart contract elsewhere.

I have it on Github at: https://github.com/learyjk/baddognft/blob/main/ABI.js

What I would like to do is have a variable in the custom code section of Webflow and just be able to call ABI so that I can instantiate a web3 contract. I was able to get it working using gitcdn.link but it's not working anymore for some reason.

Another option I played around with but wasn't able to get working were $.get("link here"). I also tried jsdelivr

but I keep getting "ABI not defined" error.

Thanks!

learyjk
  • 599
  • 1
  • 5
  • 14
  • 2
    That's not JSON when you precede it with `var ABI =`. It's then a javascript array. – charlietfl Jan 05 '22 at 02:03
  • 1
    What's the jsdelivr link you're using? Does `` work? (it does for me). Saying you tried something isn't that helpful if you don't show the relevant code from the attempt. – ggorlen Jan 05 '22 at 02:04
  • 1
    You probably at the very least want to put a CDN in front of this, if not host it elsewhere. GitHub's raw endpoints aren't supposed to be a CDN, and there are rate limits. If your repository exceeds them, you'll be asked to bring them down pretty quickly. Putting them in smart contract will generate a lot of requests. – bk2204 Jan 05 '22 at 02:59
  • Thank you @ggorlen that worked for me (I kept the variable declaration in there). Sorry I forgot to include the code. I think mine wasn't working because I had included a /blob or /dist before the file name. – learyjk Jan 05 '22 at 03:02

1 Answers1

2

You need to grab the raw version of the file from github, try changing the link to this:

https://raw.githubusercontent.com/learyjk/baddognft/main/ABI.js

Looking at the file though, you have var ABI = [// your stuff]. Which is invalid json. You have the extension correct so maybe that was just a typo in your question...

about14sheep
  • 1,813
  • 1
  • 11
  • 18
  • 2
    I don't think rawgit will work if this is part of a script inclusion. See [Link and execute external JavaScript file hosted on GitHub](https://stackoverflow.com/questions/17341122/link-and-execute-external-javascript-file-hosted-on-github) – ggorlen Jan 05 '22 at 02:07