An OpenSea.io REST API Function

JesterOC

Member
I just ported an OpenSea.io REST Function, bare with me...

( I HOPE YOU KNOW SOMETHING ABOUT BLOCKCHAIN )

It checks an ETH wallet address for an NFT asset (currently 1 per http call).

what the example shows (without changing anything):
the quantity of the checked asset "Orbiting an Epic Smile" in my own wallet and my opensea.io username of the wallet.

- FUNCTION:
osea_data_get_singleAsset( wallet_address ,token_id , asset_contract_address )

Just change out token_id and asset_contract_address to look for a different asset.

To look in a different wallet, change the first paramater to another wallet address.

For more info/download see:

...and the API reference for those interested:

and here's a screenshot of a successful NFT check (includes WAX NFTs in screenshot, but that is not included in this example).
 
Last edited:

JesterOC

Member
On an extra related side note, ive also done Atomic WAX NFTs API code for GM...
And some website codes to help implement both.. the way I have it setup it requires a backend database and login before wallet connect to connect logged in account with ETH/WAX wallets. But you could substitute the backend with your own if you wanna.

The Wallet connection uses wallet connect API.. of that i chose to use a metamask only approach.
 

MegaHogeMan

Member
Hey dude can I use this to say have a wallet login screen in my game and then only move to the next room if a certain NFT is in the wallet?
 

JesterOC

Member
You should implement a web3 wallet api(Preferably Metamask). You can then dialog with the wallet via its basic api. Opensea is a centralised NFT market, what you need is something else
Nope, he can't use this ALONE... but with my web3 code for wallet link with metamask. It (The NFT) would work like a tradeable access token... As in whoever own the NFT u require can access the next room if they link wallet.
 
Nope, he can't use this ALONE... but with my web3 code for wallet link with metamask. It (The NFT) would work like a tradeable access token... As in whoever own the NFT u require can access the next room if they link wallet.
Do you have any tutorials for the web3 stuff, or documentation I could read? I've been looking into this, but getting stuck since I can't seem to import any libraries in my JS extensions. I was going through the metamask documentation, but am struggling to implement it in GM2
 
I'm interested about this too. Can someone please detail how this is achieved to make in-game collectables into NFT and make us gain some financial benefit? Maybe make a tutorial or YT video. The other question being is this possible to implement with games made for distribution via Google Play Store. I'm worried the roadblock might be with GPS as with Apple, they are sensitive about apps having their own means of making money with them cut off the loop. Of cause I can always opt to distribute my app via other market platform.
 

JesterOC

Member
Do you have any tutorials for the web3 stuff, or documentation I could read? I've been looking into this, but getting stuck since I can't seem to import any libraries in my JS extensions. I was going through the metamask documentation, but am struggling to implement it in GM2
I haven't used a JS extension but would love to see a web3 one, would make this easier for HTML5 games... But for every other platform you're gonna need the same functionality... I'd recommend making a login for your app to collect a users wallet address with web3 access... Via WalletConnect Api.

Then u can use this Opensea Rest Api to check a users wallet for quantity of NFTs..

I'm interested about this too. Can someone please detail how this is achieved to make in-game collectables into NFT and make us gain some financial benefit? Maybe make a tutorial or YT video. The other question being is this possible to implement with games made for distribution via Google Play Store. I'm worried the roadblock might be with GPS as with Apple, they are sensitive about apps having their own means of making money with them cut off the loop. Of cause I can always opt to distribute my app via other market platform.
It is possible on google play games... Afaik... Might wanna google it . Just to be safe, don't wanna have ur user-base left in the lurch sooner or later after product release.

But if they are against u making money... Simply don't use their platform..

Personally I'm in love with itch.io.

Made myself an Android app for itch using advancedWebview for android.
Might put it on itch.io for inception.
XD (jks)
 
@JesterOC Thanks for the reply! I guess I'm still a little unclear, are you doing this in two separate steps? Like, have something outside of GM collect the info, then pass it into GM? The wallet connect api looks like is JS? Or are you having the user manually enter their wallet? The reason I didn't want to go that way is that any user could enter a wallet address that does have the token, even if it's not theirs.

When I was trying to get a JS extension working, it seemed like it was having problems with importing external JS libraries, like the web3 provider, and it also seems like you can't do 'await' or async functions in the extension.
 

JesterOC

Member
having the user manually enter their wallet? The reason I didn't want to go that way is that any user could enter a wallet address that does have the token, even if it's not theirs.
Definitely not manual entry.. for that exact reason...

Yes, i am using my website with a login connected to backend database...
Once a user logs in, i can then have them call the wallet connect code via button.
All you need do to direct them to your website is use:

open_url("login_web_url");

Once the user logs in with their wallet, collect details and use js to communicate with ur backend to save the users wallet address
 
Definitely not manual entry.. for that exact reason...

Yes, i am using my website with a login connected to backend database...
Once a user logs in, i can then have them call the wallet connect code via button.
All you need do to direct them to your website is use:

open_url("login_web_url");

Once the user logs in with their wallet, collect details and use js to communicate with ur backend to save the users wallet address
Thanks for the reply! I actually ended up getting it working with JS extensions. The sticking point was that in order to include external JS libraries, you have to import them by editing the HTML5 doc, you can't add them in the JS doc. Once I figured that out, I could just follow some other JS examples to get it working. There's also a GM_API for JS that I guess isn't in the documentation. But it let's you send async messages back to GM.
 

JesterOC

Member
Lovely..
Thanks for the reply! I actually ended up getting it working with JS extensions. The sticking point was that in order to include external JS libraries, you have to import them by editing the HTML5 doc, you can't add them in the JS doc. Once I figured that out, I could just follow some other JS examples to get it working. There's also a GM_API for JS that I guess isn't in the documentation. But it let's you send async messages back to GM.
Glad to hear you got it working. 🙂
Mind telling me what you're planning on making?

At the moment I only have daily rewards set up for my own project..
I plan on adding some NFT's that grant features in-game... Such as "Gun Customizer" and maybe a really cheap novelty pass... Like a library card, where the game won't let you in unless you have one... Or a master key that can open any chest... (User can sell said NFT(s) to friends or whoever once they are finished with it) (AND U GET NFT ROYALTIES ON TRADES)

PS:
I'm thinking of uploading the WAX NFTs code.. and maybe the web code?
Like this post if you want Atomic Wax API and/or wallet login website codes.
 
Lovely..
Glad to hear you got it working. 🙂
Mind telling me what you're planning on making?

At the moment I only have daily rewards set up for my own project..
I plan on adding some NFT's that grant features in-game... Such as "Gun Customizer" and maybe a really cheap novelty pass... Like a library card, where the game won't let you in unless you have one... Or a master key that can open any chest... (User can sell said NFT(s) to friends or whoever once they are finished with it) (AND U GET NFT ROYALTIES ON TRADES)

PS:
I'm thinking of uploading the WAX NFTs code.. and maybe the web code?
Like this post if you want Atomic Wax API and/or wallet login website codes.
I'm working on something similar! The NFTs will be your character, but also the key to be able to play the game. People have talked about the utility of NFTs in games for a long time, but not that many people have done it yet. So I'm exploring this usage as a different form of monetization. In the future I will incorporate more NFTs into the game, most likely on polygon to get around the fees, and hopefully some kind of method to let other people make NFTs that can be pulled into the game as well. Huge project for sure haha, but it's a lot of fun figuring this stuff out.
 

JesterOC

Member
...some kind of method to let other people make NFTs that can be pulled into the game as well.
I have thought about doing this also, depending on NFT standard and api that u use, you can probably just have users copy paste the tokenID of the NFT they want to use in-game as character...
Check their wallet for that ID and then if all is successful, download the image and save it for use as a character...

Edit: Although.. you might wanna check size of the NFT image dimensions, so as not to load a giant/tiny image as character... and try lookout for NSFW images if multiplayer.
Also, u could maybe have a property [YOURGAME]_character that users can add to their NFT's that u can use to identify NFT's as character viable for ur game... That'll also help boost sales and gain popularity because it's then searchable ( people can then make assets for YOUR game (That they can even sell, no money in ur pocket, but u get plenty of free user-made assets) )
 
Last edited:
I have thought about doing this also, depending on NFT standard and api that u use
yeah that's basically what I was thinking. Except I would have 'approved' sellers. So they would be given a standard size template, and I would just include their contract address in my code. That way it wouldn't be a free for all with people uploading all kinds of bad stuff haha.
 

JesterOC

Member
Yeh? How would you approve them?
Manually? or via some code? Or a bit of both?

What about Opensea NFT's with the OPENSEA storefront contract address? They all use the same contract address if I'm not mistaken?

I was thinking i'd just use a "report" button as well as implementation of banning users from custom NFT use if reported by X amount of users or more in a month...

That's still way off for me tho..

5 years into my solo project, the multiplayer, NFT's, art-needs, story and itemcrafts have bundled into what looks like another 3-5 years work...
(First game, 😳 I hope people like it... Or thats a lot of time wasted)
 
Yeh? How would you approve them?
Manually? or via some code? Or a bit of both?

What about Opensea NFT's with the OPENSEA storefront contract address? They all use the same contract address if I'm not mistaken?

I was thinking i'd just use a "report" button as well as implementation of banning users from custom NFT use if reported by X amount of users or more in a month...

That's still way off for me tho..

5 years into my solo project, the multiplayer, NFT's, art-needs, story and itemcrafts have bundled into what looks like another 3-5 years work...
(First game, 😳 I hope people like it... Or thats a lot of time wasted)
Hey! Sorry things got way busy. For now the intention would be to just like make an agreement with a specific artist and say, here's the dimensions etc. And then add their stores contract address to the games code. So ONLY items from shops coded into the game could be used. And then we can control the content that is allowed into the game, so no offensive or obnoxious items would be allowed. I'll look into that storefront contract address though, if we could just add artists to that same contract address, it would make things easier.

I'm also trying to pull in the tokens traits, but can't seem to figure out what to grab from the json data. Like, the ownership_map in the json is a dictionary, but the traits is just a list, so I'm struggling to find the right way to grab that whole list as like an array or something.
 
Last edited:

cev987

Member
Does anyone know how detection of the MetaMask could be accomplished via a stand alone application (.exe) in windows? I am targeting only the Windows OS. Much would be appreciated. Currently I am using
JesterOC example but the issue is as stated by another user the user may just enter someone else's wallet with the token id and contract address lol :(.
 

JesterOC

Member
Does anyone know how detection of the MetaMask could be accomplished via a stand alone application (.exe) in windows? I am targeting only the Windows OS. Much would be appreciated. Currently I am using
JesterOC example but the issue is as stated by another user the user may just enter someone else's wallet with the token id and contract address lol :(.
As far as i know, u can't just use "MetaMask" in .exe as it's a browser extension for Google Chrome... (There's also a mobile app but i find it useless)

But why stop at .exe???

My application is an .exe...
I use MetaMask integration after user logs into the application on website...(same credentials as users in project database) To send the user there you only need call open_url(wallet_link_url).
Then u just need to save the wallet address after login...
 

cev987

Member
As far as i know, u can't just use "MetaMask" in .exe as it's a browser extension for Google Chrome... (There's also a mobile app but i find it useless)

But why stop at .exe???

My application is an .exe...
I use MetaMask integration after user logs into the application on website...(same credentials as users in project database) To send the user there you only need call open_url(wallet_link_url).
Then u just need to save the wallet address after login...
Bro I got this thing working so damn happy! I can now make some really epic projects! XD Thank you so much for releasing the source code guys!
Mytchall Bransgrove and JesterOC
 
Hey everyone,

I'm playing around with @Mytchall Bransgrove 's project and successfully had it recognize an ERC-20 in my address.

However, for an ERC-1155 NFT it does not work, always fails to return the balance.

I'm assuming this has to do with the function getTokenBalance and the fact the minABI is set for ERC-20s. What would an ABI for an ERC-1155 look like?

Thanks
 

Mert

Member
Hey everyone,

I'm playing around with @Mytchall Bransgrove 's project and successfully had it recognize an ERC-20 in my address.

However, for an ERC-1155 NFT it does not work, always fails to return the balance.

I'm assuming this has to do with the function getTokenBalance and the fact the minABI is set for ERC-20s. What would an ABI for an ERC-1155 look like?

Thanks
I have made an extension for a project of mine, and was able to do that. Specs are available here https://eips.ethereum.org/EIPS/eip-1155
I want to share my extension with you, but needs some tweaking (Adjusting it to BEP & Polygon MATIC standarts. Also looking for a solution for Solana ecosystem as NFTs are really growing large in that chain)
 

ogfuntime

Member
@JesterOC Thanks for all this great info. I was curious if you could point me in the right direction for what I would like to do. I am still learning a lot about coding. I have a game in GM I am making. I want to have the NFTs act as a key to allow players to access the game. That I understand. But, I am not sure how I could go about attaching game save data to people's NFTs. How would you accomplish this?
 

JesterOC

Member
@JesterOC Thanks for all this great info. I was curious if you could point me in the right direction for what I would like to do. I am still learning a lot about coding. I have a game in GM I am making. I want to have the NFTs act as a key to allow players to access the game. That I understand. But, I am not sure how I could go about attaching game save data to people's NFTs. How would you accomplish this?
I use a website.
I have the user login... Press button to connect wallet... Save the wallet address in the game's database... #done...

All your users save data should be in a Database...
 

ogfuntime

Member
Makes sense. I was thinking of the game save data being attached to the NFT somehow. I realize now that isn't the way. Thank you!
 

chiamikaa

Member
I use a website.
I have the user login... Press button to connect wallet... Save the wallet address in the game's database... #done...

All your users save data should be in a Database...
So basically that site just works to populate your DB with the player's account, where they can link their wallet ID to it and thus be able to use the API to confirm that they are the asset holder. Do you have any scripts or assistance in creating such a wallet link for people to login with? That's the part I'm running into an issue with doing correctly.
 

JesterOC

Member
So basically that site just works to populate your DB with the player's account, where they can link their wallet ID to it and thus be able to use the API to confirm that they are the asset holder. Do you have any scripts or assistance in creating such a wallet link for people to login with? That's the part I'm running into an issue with doing correctly.
Creating a wallet address is usually done by the end-user... Usually on a website or Dapp.
I have never used a script to make a wallet...
I use metamask fer OpenSea nfts, Wax Wallet fer atomichub wax NFTs...(best imo)

Maybe Google "how to get a crypto wallet" if you don't know...
 

Chaser

Member
Metamask and opensea API’s have have shown vulnerability’s, what risks are there implementing a GM code based wallet Connection? How secure is it?
 

JesterOC

Member
Metamask and opensea API’s have have shown vulnerability’s, what risks are there implementing a GM code based wallet Connection? How secure is it?
The GM based code is just a REST based lookup... There is no connection...
The actual wallet connect code is not provided... Tho i use wax wallet connect on my website these days, rather than metamask/OpenSea...

(Opensea eth charge heaps for gas... anyhow...)

What particular risks where you wondering about?
 

Chaser

Member
My assumption was they would need to connect their wallet to with their NFTs, using your metamask ‘passphase’? Or sign in through metamask to connect to game? If this is the case, how secure is it, what’s stopping someone using your extension/code to exploit users to obtain their metamask credentials.
If that’s not the case, how are The NFTs being verified?
Sorry, I don’t mean this to come across as negative, that’s not my intention.
 

Mert

Member
My assumption was they would need to connect their wallet to with their NFTs, using your metamask ‘passphase’? Or sign in through metamask to connect to game? If this is the case, how secure is it, what’s stopping someone using your extension/code to exploit users to obtain their metamask credentials.
If that’s not the case, how are The NFTs being verified?
Sorry, I don’t mean this to come across as negative, that’s not my intention.
This is not how crypto transactions work!

(Assuming that there are no tricky hacks and stuff).. Metamask does not expose user credentials like secret passphrases to outside world. Metamask does have only one job: To sign transactions on behalf of you.

In order to do transactions on blockchains, you need to sign it so that the authenticity of the operation is confirmed. This happens when your secret passphrase is super encoded(So encoded that only billions of dollars machinery of "Proof of Work" machines around the world confirms it)

How NFTs are verified = An NFT is basically a smart contract, living on the blockchain. If your wallet owns it, then you own it. You can also verify its authenticity(there may be copies of the original NFT right), checking the creator wallet address / Tx data etc.


Edit : In case someone wonders how minting works. Since NFTs are EIP-721 standart, you can customize their base smart contract. Most of the projects do let players mint NFTs when certain conditions are met. You usually left a function in your NFT's smart contract. Thereafter, you transact with the minting function which then sends the minted NFT into your wallet. Rest is basically checking whether your wallet owns the NFT.
I know it because I have a test Game Maker project and minted NFTs on Binance Smart Chain Testnet (Basically an Ethereum fork)
 
Last edited:

Mert

Member
‘ connect to metamask’, so what happens when I select this option?
Does absolutely nothing
This button is there to warm up the scene. By clicking it, you kinda let the browser/platform know that Metamask is installed on your computer and you can do transactions.
(Think it like : If Google Play Services are installed on your phone, then you can have achievements, scores etc.)

To sign into the platform with your metamask, there's another function that opens the "Sign In" page where you sign a basic process and the platform gets to know your public wallet id.
 
I just ported an OpenSea.io REST Function, bare with me...

( I HOPE YOU KNOW SOMETHING ABOUT BLOCKCHAIN )

It checks an ETH wallet address for an NFT asset (currently 1 per http call).

what the example shows (without changing anything):
the quantity of the checked asset "Orbiting an Epic Smile" in my own wallet and my opensea.io username of the wallet.

- FUNCTION:
osea_data_get_singleAsset( wallet_address ,token_id , asset_contract_address )

Just change out token_id and asset_contract_address to look for a different asset.

To look in a different wallet, change the first paramater to another wallet address.

For more info/download see:

...and the API reference for those interested:

and here's a screenshot of a successful NFT check (includes WAX NFTs in screenshot, but that is not included in this example).
Oh wow, nice.

I'm going to use this so that if you have an OpenSea account, it instantly deletes all your save data and tells you to go 💩💩💩💩 yourself.
 

JesterOC

Member
Oh wow, nice.

I'm going to use this so that if you have an OpenSea account, it instantly deletes all your save data and tells you to go **** yourself.
That's the worst idea I've ever heard... The user volunteers to add their eth address... There's actually no code in there that checks for an openSea account...

I really think NOBODY will play your **** cus that's what it'll be...

Deleting user save data is you being a ****ing ***hole.
K thanks Bye
 

Chaser

Member
So the ‘connect to metamask’ is like a placeholder. oK.

The public wallet, this shows you own the NFT?, and by ‘connecting’ your public wallet ID this verifies you own the NFT?
Or by signing into Opensea account(via extension) this shows what NFT’s you own, and connects via that?
 

Chaser

Member
I maybe have, which is why I’m trying to understand. Let me try again.
How does the extension verify owners of specific NFTs that can be used in game created by GMS?

“User volunteers to add their eth address” explain?
 

JesterOC

Member
I maybe have, which is why I’m trying to understand. Let me try again.
How does the extension verify owners of specific NFTs that can be used in game created by GMS?

“User volunteers to add their eth address” explain?
Users wallet address doesn't get collect by the extension... They have to login to metamask on your website
.. You do the collection of the address on your website with metamask or walletconnect codes...
Once logged in u have the address in the code... U save it to ur Online database...

User logs in to your project...

Now the extension can work its magic... It uses OpenSea's api to check owned nft of eth address for ur user ... It returns an async event you need to handle ..
 

JesterOC

Member
I see, thanks for the explanation. :)
The idea that it can save address to database is a big concern for me. You say it uses no code to use opensea account, and then say it uses Openseas api to check accounts once logged in via metamask in the browser.
IMO, My biggest concern really was how safe and secure the set up is and reading your reply’s I’m not convinced. I fear this tool will be exploited and used for bad things, despite your good intentions. No sign in, but can volunteer their eth address seems strange to me. But then that’s just me. Lol.
I shan’t bother you anymore mate, I wish you all the best.:)
It doesn't do what u just said...
I didn't say user don't sign in..
K. Thanks bye.. please don't bother me again... I get notified every response to my topic...

In case anyone is wondering... The OpenSea Account is what the code doesn't contain... It simply checks an eth address with OpenSea API
 

Japster

Member
It doesn't do what u just said...
I didn't say user don't sign in..
K. Thanks bye.. please don't bother me again... I get notified every response to my topic...

In case anyone is wondering... The OpenSea Account is what the code doesn't contain... It simply checks an eth address with OpenSea API
Hey man, sorry to @ you, but just to say, ignore all of this crap mate - just wanted to say I am using this just fine, and I *REALLY* appreciate your hard work! 👍👍

I cannot believe the sh*t you're getting from people who simply do NOT understand how blockchain (and checking it indirectly via OpenSea's API) works...

Makes me really reluctant to share any blockchain tech myself, reading these reactions, responses and queries...

These people need to understand that there's a BIG difference between using API functionality (and NO, NOT logging into OpenSea), to query who owns an NFT, and actually connecting your wallet to OpenSea, LOGGING IN YOURSELF, and having full access to your OpenSea settings / holdings... SMH....


So... ...To the people being uneducated (but opinionated!) d*cks (*) on here:-

So if @JesterOC made a helpful extension to let you just READ token balances using the (totally transparent and auditable) Blockchain or another API (Moralis, Alchemy etc), I'm betting right now, that some of the rocket scientists on here p*ssing on his current FREE offering, will swear blind that it will ALSO allow you to SEND the funds, and clean their account out, so "Thanks, but NO thanks... Lolz"?!

You guys REALLY need to read up on Blockchain before you start assuming stupid things and security 'concerns' that aren't even possible!... Don't be afraid to ask, but for crying out loud... ....at least first check the internet with your concerns, and at least read up on it if you are trying to get into coding games for it?!

I've written over a dozen Blockchain-aware games now, and used Jester's extension for 3 of them that are NFT-based - Obviously, not one NFT or account has been affected, because we're simply using wallet connect to verify that the person playing OWNS that wallet, and THEN checking the API (as ANYONE can, interactively, at OpenSea's site (even via PASTING a wallet into the 'try it' option), to return a full list of NFT's owned by that wallet)...

...Oh yeah, and good luck sending ANYTHING on behalf of a user's wallet, without their PRIVATE KEY. NOTHING will sign/go through without that, hence it's as secure as your private key is - if YOU divulge it, then it's your stupidity.... 🙄

Basically, if you NEED to send tokens or NFTs automatically, for P2E, NFT minting, etc, then the only way to do it is eg. by having a designated 'treasurer' etc wallet, whose private key is known to the back-end server solution that's doing it, and coding or calling WEB3 contract functionality to do so...

...and NOT by simply calling Jester's extension's functions... 🙄

Had to try and clear this up - I HATE misguided mis-information and unwarranted negativity, when someone's kind enough to share GOOD work with the community... 😠

JesterOC? - Don't let it get to you dude - there are way too many opinionated 'armchair expert' noobs around, but I can promise you - your hard work and generosity IS appreciated mate... 👌👍


(*) Ducks... 😉
 

Chaser

Member
Wow, there was no need for that. I’m entitled to my opinion, and I’m entitled to ask questions, you know, to help my understanding. Sadly, I wasn’t convinced by the answers.

The blockchain isn’t my concerns, and if I’m to educate myself on that then maybe you should educate yourself on the actual NFT space. Have you seen it? Have you seen what a 💩💩💩💩show Opensea is?, game projects aside, the NFT is littered with scams, phishing, plagiarism. Content creators are being exploited all the time and as jesters is and has created content they could well be effected too. And in this instance, their extension.

Now, I do feel a little stupid asking and perhaps my comment is a negative one, but I meant no harm, and I did wish jester well for their endeavours, and I do appreciate those that do create content for others.

Your attitude is disappointing, supporting jester is great but bashing others isn’t cool with name calling and whatever else. I’m not surprised by it, as everyone I have met within the NFT/ blockchain community’s is always the same but a fair few. Instead of listening to concerns, or feedbacks in a constructive way, the result is to insult and say things to belittle them.

I can appreciate that your angry and frustrated, but you know what, I’m angry and frustrated too mate. The only difference is we are both on different ends of the spectrum on this NFT/blockchain journey.

I apologise to jester for commenting, as I said I wouldn’t. So this will be my last post here, if you want you can PM me, but don’t be rude or abusive If doing so.

If this post is generating negative responses, I will ask admin to delete my comment.
 
Top