Current location: Current location: Home > code > Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep243 Text
Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep243
[code] Time: 2025-07-11 11:41:18 Source: AIHackNode Author: php Click: 17 times
to note is trailblazing womenthat it didn'tclear out our last event right the lastevent and if I go R mint and list againafter it completes we'll have anotherevent inhere okay this is great so all of thisis being said the reason we're doing allthis in the first place is so that inour index.js we can start listening forevents how do we show the recentlylisted nfts so now we have a database oflisted nfts so what we could do we couldjust query this item listed table rightand grab everything in here however wehave an issue here what happens ifsomeone buys an nft if someone buys annft the item listed event will still bein our database but technically it won'tbe on the marketplace anymore it'll begone it won't be listed so what can wedo there's a number of architecturalchoices we can make to get around thisproblem to solve this problem but one ofthe things we can do is actually we canuse Morales Cloud functions so MoralesCloud functions allow us to just reallyadd anything we want our front end to dofrom the morale server and these arefunctions these are scripts that aregoing to run on our morale serverwhenever we want them to so we come toour server we hit the little dropdownand we hit Cloud functions now this iswhere we can write some Morales stuff torun on our server whenever we want andwe are going to set up our Cloudfunctions in our ID by hitting thislittle drop down to actually sync up ourVisual Studio code with our Cloudfunctions we can just run this commandhere and it'll add whatever Cloudfunctions we have in some Cloud folderto here so what we can do back in our vscode let's make a new folder new foldercalledCloud functions and in here we'll createa new file called update active items.JS so in here if we were to writesomething likeconsole.log hi we can actually have thisautomatically save on a moral server andthe way that we do this is by runningthis command now we want to make it sothat it's a lot easier for us to runthis command than just always having torun this massive thing so what we'regoing to do is we're going to open upour package.json and we're going to makeanother Morales script here so rightbelow here we're going to make anotherMorales script we're going to sayMorales Morales cloud and we're going tohave it run this command so we're goingto copy this command here paste it intoour package Json so it's going to beMorales admin CLI watch Cloud folder wedon't need the moral API key cuz it'llgrab that from our environment variableswe don't need the moral SE because it'llgrab that from our environment variableswe do need the Morales subdomainautosave one and then the Morales Cloudfolder is going to be that new Cloudfunctions bit that we made SL Cloudfunctions functions now in a newterminal if I run yarn Moralis Cloudwhich is going to be the same as runningthis huge function here I hit enterit'll say compile you know version blahblah blah compile F in blah blah blahchanges uploaded correctly and if we goback to our front end we can see thisconsole.log high and our front end beingupdated and if we continue to run thisin our update active items at. JS wecould also writeconsole.log yo save it and if this isstill running it'll automatically uploadit and now we can see if we do a littleRefresh on our front end Cloud functionswe can see it's been uploaded here nowat this point if you have a ton of thisstuff running you might see CPU 100% youmight see this little thing pop up andthe server might start going a littlebit slower we're starting to use a lotof network activity here so I'm going toclose my yarn Morales Cloud for now andI'm just going to upload it once when Ineed to cuz we're connected we have itlistening to events we're having itdoing more and more stuff here and itcan start to put a lot of load onto theserver so we're just going to go aheadwe're going to cancel it out and now theCPU is a lot lower but if we go back toCloud functions we can see it's still inhere here and anytime we update ourCloud functions it'll update our serverwith those Cloud functions and we'lljust run that jarn moras cloud oncewe're all done here anyways so right nowwe're trying to figure out okay we haveitem listed but if someone buys an itemtechnically it won't be listed anymorebut our item listed table will stillhave it listed so what we can do is wecan create a cloud function that runswhenever we want and like I said we canhave these run whenever we want we cancall these whenever we want but we'regoing to create a clown function thatonly runs runs whenever one of theseevents are synced item listed itemcanceled or item bought we're going tocreate a new table called active item anactive item is going to say okay anytimeit's listed it'll be active but whenit's bought or canceled we'll remove itfrom the active item list so we're goingto create a new table so let's go aheadand do that we start off with more Alicedo and then if you're if it auto doesthat you don't need this uh we don'tneed to import Morales here becausewe're going to upload it as a cloudfunction and our server already justautomatically injects Morales into ourscripts so we're going to say moral.cloud.aftersave and there's a whole bunch ofstuff you can do with your moral. cloudand again you can find these all in thedocumentation the after save keywordmeans that any time something gets savedon a table that we specify will dosomething and it takes two parameters soit takes what table that we want to dosomething after it's saved and we'regoing to say item listed so we're sayinganytime something is saved to the itemlisted table we'll run some asyncfunction and we'll put request in herebecause anytime something gets saved itcomes with a request so anytime an itemlisted happens we want to add it to ouractive items
(Editor in charge: news)
Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep63Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep226
Related content
- GenAI Essentials – Full Course for Beginners - Ep171
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep139
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep153
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep25
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep1
- Artificial Intelligence Full Course _ Artificial Intelligence Tutorial for Beginners _ Edureka [DownSub.com](1).txt - Ep18
- [Hindi (auto-generated)] Machine Learning FULL Course with Practical (10 HOURS) _ Learn Free ML in 2025 _ Part-1 - Ep69
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep121
- Psycho Killer _ Interview with a Killer S2 E1_ Gary Hilton - Ep5
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep58
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep116
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep250
- Artificial Intelligence Full Course _ Artificial Intelligence Tutorial for Beginners _ Edureka - Ep28
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep80
Wonderful recommendations
- GenAI Essentials – Full Course for Beginners - Ep108
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep84
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep100
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep19
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep137
- Generative AI Full Course – Gemini Pro, OpenAI, Llama, Langchain, Pinecone, Vector Databases & More - Ep87
Popular Clicks