Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » In game assets as NFTS, smart contracts?
- masoluka
- Scratcher
26 posts
In game assets as NFTS, smart contracts?
Alo, fellow Scratchers, I have 3 questions, thank you for the answers.
a. General databases: Is there a way to communicate (write to, read from) with external database from Scratch (mysql or any other database)?
b. Blockchain: Is there a way to check / verify ownership of a certain nft (non fungible token) to be able to use a sprite / costume in Scratch?
c. Blockchain: Is there a way to write to blockchain via smart contracts from Scratch?
Use cases:
- I need to sign-up and log-in player, have it stored in my database with some variables to track progress
- User needs to own certain NFT non-fungible token (solana, polygon,..?) to access certain in-game assets - car, ship, whatever
- If something happens in the game (someone won an in-game asset ~ NFT), it gets written on a blockchain via smart contract
a. General databases: Is there a way to communicate (write to, read from) with external database from Scratch (mysql or any other database)?
b. Blockchain: Is there a way to check / verify ownership of a certain nft (non fungible token) to be able to use a sprite / costume in Scratch?
c. Blockchain: Is there a way to write to blockchain via smart contracts from Scratch?
Use cases:
- I need to sign-up and log-in player, have it stored in my database with some variables to track progress
- User needs to own certain NFT non-fungible token (solana, polygon,..?) to access certain in-game assets - car, ship, whatever
- If something happens in the game (someone won an in-game asset ~ NFT), it gets written on a blockchain via smart contract
Last edited by masoluka (Jan. 21, 2022 16:47:34)
- Chiroyce
- Scratcher
1000+ posts
In game assets as NFTS, smart contracts?
After a quick look at your post, i think you would want this.
- A server running 24/7, preferably Python/NodeJS that has
- A database system (MySQL, SQLite, MongoDB)
- A script using meowJS (for NodeJS) or scratchclient (for Python).
So that script should be able to look through the Cloud Variables being set in the project by the user, and then accordingly save the data in the database. You can also read from the DB and write to the project's cloud variables, this will require your Scratch account's credentials. This is an unofficial way, both meowJS and scratchclient are open source, so the risk is very low, but still, use at your own risk.
I also do recommend reading this post to understand limitations/drawbacks of using servers to interact with cloud variables.
- A server running 24/7, preferably Python/NodeJS that has
- A database system (MySQL, SQLite, MongoDB)
- A script using meowJS (for NodeJS) or scratchclient (for Python).
So that script should be able to look through the Cloud Variables being set in the project by the user, and then accordingly save the data in the database. You can also read from the DB and write to the project's cloud variables, this will require your Scratch account's credentials. This is an unofficial way, both meowJS and scratchclient are open source, so the risk is very low, but still, use at your own risk.
You would have to make a program that interacts with scratch cloud variables (requires account credentials for writing to it) and it should also have access to the server. the easiest way to do this would be to use a. General databases: Is there a way to communicate (write to, read from) with external database from Scratch (mysql or any other database)? SQLite and Scratchclient, via Python.
Assuming that the blockchain is outside of scratch - yes, but it wouldnt be allowed to not let a user use a costume just because they dont own an NFT. b. Blockchain: Is there a way to check / verify ownership of a certain nft (non fungible token) to be able to use a sprite / costume in Scratch?
Same as the first one, but make sure to validate the user data really well, someone can get full access to your crypto accounts otherwise. c. Blockchain: Is there a way to write to blockchain via smart contracts from Scratch?
If it's your OWN blockchain, like in an SQL database, totally fine. If it's an actual one, then there might be issues with it. - If something happens in the game (someone won an in-game asset -NFT), it gets written on a blockchain via smart contract
I also do recommend reading this post to understand limitations/drawbacks of using servers to interact with cloud variables.
Last edited by Chiroyce (Jan. 21, 2022 14:32:39)
April Fools' topics:
— New Buildings in Scratch's headquarters
— Give every Scratcher an M1 MacBook Air
— Scratch should let users edit other Scratchers' projects
— Make a statue for Jeffalo
— Scratch Tech Tips™
— Make a Chiroyce statue emoji
<img src=“x” onerror=“alert('XSS vulnerability discovered')”>
this is a test sentence
- NanoRook
- Scratcher
1000+ posts
In game assets as NFTS, smart contracts?
Chiroyce has given some really great advice but I don't think NFTs would interact well with how Scratch is built. Putting my own biases aside for a second, NFTs are based around the fact that the NFT you own is unique to you and you alone as established on the blockchain contract. However, everything on Scratch can be easily remixed and modified by anyone–a feature that's built into the platform and its philosophy. If you're planning on letting people sell their Scratch NFTs then I imagine anyone being able to make their own identical copy will seriously devalue it.
I LOVE BEING PURPLE!!!! JOIN THE PURPLE COALITION TODAY IF YOU ALSO LOVE BEING PURPLE. PURPLE IS THE NEW BLUE! PURPLE IS THE SUPERIOR NAVBAR COLOR! YYYEAAHHHHH BABY!!!!
- masoluka
- Scratcher
26 posts
In game assets as NFTS, smart contracts?
Thank you guys for the answers.
In response to @NanoRook I'd have user registered in my DB (not Scratch DB) and if user has an NFT in the wallet, it would reflect that in my DB, after that I'd pass it to cloud variable param in Scratch DB to unlock use of some costume (say upgraded ship, weapons, whatever). In that case I don't think there is any problem, coz NFTs are held in wallets by players, far away from Scratch.
In response to @Chiroyce first thank you for all of the answers. Considering the limitations and convoluted stack I'd have to use here, combined with some more issues, such as a need for a project to have a multi-touch funcionality for mobile devices (Scratch doesn't support that), and also, would need to offer multiplayer for nonscratchers (open multiplayer), would you consider porting the whole project outside of Scratch for further development? If so, I've tried porting to js via lepoard and translation is.., well broken, I've seen porting to phyton, couldn't get it to work for now…, what would you do if you had a project that needs further dev in those directions? What are important considerations here, experiences maybe?
Many thanks.
In response to @NanoRook I'd have user registered in my DB (not Scratch DB) and if user has an NFT in the wallet, it would reflect that in my DB, after that I'd pass it to cloud variable param in Scratch DB to unlock use of some costume (say upgraded ship, weapons, whatever). In that case I don't think there is any problem, coz NFTs are held in wallets by players, far away from Scratch.
In response to @Chiroyce first thank you for all of the answers. Considering the limitations and convoluted stack I'd have to use here, combined with some more issues, such as a need for a project to have a multi-touch funcionality for mobile devices (Scratch doesn't support that), and also, would need to offer multiplayer for nonscratchers (open multiplayer), would you consider porting the whole project outside of Scratch for further development? If so, I've tried porting to js via lepoard and translation is.., well broken, I've seen porting to phyton, couldn't get it to work for now…, what would you do if you had a project that needs further dev in those directions? What are important considerations here, experiences maybe?
Many thanks.
Last edited by masoluka (Jan. 21, 2022 17:07:43)
- Chiroyce
- Scratcher
1000+ posts
In game assets as NFTS, smart contracts?
Can you clarify if it's an actual crypto wallet or just one that doesn't involve money (like in a database managed by you) if user has an NFT in the wallet
It depends, here, the server side scripting has to be done outside of scratch, and the game inside itself. If you want this outside of scratch, the same backend will be required, but a different client facing game. You could use Unity/Unreal engine for professional game making, or you can would you consider porting the whole project outside of Scratch for further development?convert the scratch project into HTML.
April Fools' topics:
— New Buildings in Scratch's headquarters
— Give every Scratcher an M1 MacBook Air
— Scratch should let users edit other Scratchers' projects
— Make a statue for Jeffalo
— Scratch Tech Tips™
— Make a Chiroyce statue emoji
<img src=“x” onerror=“alert('XSS vulnerability discovered')”>
this is a test sentence
- masoluka
- Scratcher
26 posts
In game assets as NFTS, smart contracts?
It depends, here, the server side scripting has to be done outside of scratch, and the game inside itself.
OK, let's say for starters, a simple example, I have a score (and many others) variable in scratch game and would like to pass the value (current score) at any time to my external database. How can I do that consistently and accurately? Tx.
Last edited by masoluka (Jan. 22, 2022 21:54:11)
- ScolderCreations
- Scratcher
1000+ posts
In game assets as NFTS, smart contracts?
It's a bit complicated, but you'll need to create a program on the server that can decode cloud variables, and on the client side, the scratch project, create a system that takes the information and the user identifier, such as a token, combines them, and encrypts them into numbers.
- masoluka
- Scratcher
26 posts
In game assets as NFTS, smart contracts?
After a quick look at your post, i think you would want this.
- A server running 24/7, preferably Python/NodeJS that has
- A database system (MySQL, SQLite, MongoDB)
- A script using meowJS (for NodeJS) or scratchclient (for Python).
So that script should be able to look through the Cloud Variables being set in the project by the user, and then accordingly save the data in the database. You can also read from the DB and write to the project's cloud variables, this will require your Scratch account's credentials. This is an unofficial way, both meowJS and scratchclient are open source, so the risk is very low, but still, use at your own risk.You would have to make a program that interacts with scratch cloud variables (requires account credentials for writing to it) and it should also have access to the server. the easiest way to do this would be to use a. General databases: Is there a way to communicate (write to, read from) with external database from Scratch (mysql or any other database)? SQLite and Scratchclient, via Python.Assuming that the blockchain is outside of scratch - yes, but it wouldnt be allowed to not let a user use a costume just because they dont own an NFT. b. Blockchain: Is there a way to check / verify ownership of a certain nft (non fungible token) to be able to use a sprite / costume in Scratch?Same as the first one, but make sure to validate the user data really well, someone can get full access to your crypto accounts otherwise. c. Blockchain: Is there a way to write to blockchain via smart contracts from Scratch?If it's your OWN blockchain, like in an SQL database, totally fine. If it's an actual one, then there might be issues with it. - If something happens in the game (someone won an in-game asset -NFT), it gets written on a blockchain via smart contract
I also do recommend reading this post to understand limitations/drawbacks of using servers to interact with cloud variables.
Let's start very simple please with basic leaderboard to get the clear picture:
I have:
- A working leaderbord in Scratch, it uses my sessionID while logged in and limited to Scratchers. Project is currently not shared, ie. unshared.
I need:
- A leaderboard for nonscratchers / everyone, after project is html-zed / apk-ized how do I change cloud variables' values (score & name ~ as typed in by user), when there is no sessionID or should I connect myself programaticly to achieve this?
So, random people play the game on website (htmlized Scracth project), if their score is high enough, they are asked for a name and listed on a scoreboard.
Question: How do I access cloud variables in this case, what block / syntax should I use to have a sessionID open, so that their values get stored in cloud variables in the first place? Or is there any other meaningful way to achieve the same goal, ie at the end of the game, check if score is high enough -> collect a name -> list on leaderbord.
Thank you.
Last edited by masoluka (Jan. 25, 2022 18:18:45)
- Discussion Forums
- » Advanced Topics
- » In game assets as NFTS, smart contracts?