-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!

4
  • 2
    That's not JSON when you precede it with var ABI =. It's then a javascript array. Commented Jan 5, 2022 at 2:03
  • 1
    What's the jsdelivr link you're using? Does <script src="https://cdn.jsdelivr.net/gh/learyjk/baddognft/ABI.js"></script> work? (it does for me). Saying you tried something isn't that helpful if you don't show the relevant code from the attempt. Commented Jan 5, 2022 at 2: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. Commented Jan 5, 2022 at 2: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. Commented Jan 5, 2022 at 3:02

1 Answer 1

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...

Sign up to request clarification or add additional context in comments.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.