Factories vs single-sided contracts [workshop] by vasapower.eth (@vasapower_)

ETHDubai 2023 · 15 Mar 2023 · 41:38

Toschi.eth and vasapower.eth explore factories and single-sided contracts through EthereansOS, including how developers can interact with the platform.

Speakers

Topics

From ETHDubai 2023, hosted by DeFi Dubai.

Transcript

foreign [Music] [Music] about the house

he's really about organization managed by a team that for example Pilates performances of the voters through all chain and tools that very overall like Snapchat for example do you really think that the type of doubts are really decentralized and autonomous because 99 pieces this is a fair note really is centralized because of the teeth has the key

s to manage all the changes inside the house and they collected us to progresses all the brothers and so they're choosing as a special permissions to do what they want and nobody can do anything in business shoes preferences and the team is not a case of fatigue they produce Technologies and this is not how decentralization of

everything works and because everything in ethereum is not just behind that and where is this now in the in our description of all the just a bunch of people now where is love released between transparencies 2015 on trainings that's the problem think about it and this is one of the challenges foreign

[Applause] today and leave the system and totally unchain never landed the the hope of the voters to know us to begin the protagonist of attacking and chain for real and so this is that you don't have to um what about the TV does because everything is best advise.com that can let people move forward

in this environment because if you can go to executive physical change hello into the SE organizations and this is also later if you think about it because changing everything Ventures for everybody for example manage the economy of organizations or whatever so change because there are no common and multiple assumptions so you are you also degraduated and definitely a

disadvant the the way that the team can manage directly organization so what could be a solution to to bypass this program and a bunch of Christian choices people can set when they create their organization and an old organization through stock for example that recessed model the automobile every time the perfect example a factory concept with some customizable sets that you can do when you create your organization communication must give close changes

solved what you see was what we get but open to exception create an organization that that was a very own professional and people can choose where to go in the near Ocean but everything is good I plan 100 banana and if you think about it this is a hardware when you have into great decision environment for successful in Amazon Marketplace

you have all structure and adjustable two products can you look like the entire ecosystems in the entire environment is meditation and offered by Amazon or for example for Twitter you can just hold treats with a little set of characters but nothing normal if you think about the software Twitter what is the structure and give them the content and this is what we we created we could relax [Music] and you are

a group personal assistant secretary so this is our tools for example we can create your own platform this is that you can create your own factors and let people create your platform and this is all that everyone can choose what operation of them to a platform because

you know this is not about doing justice of once in my contact but otherwise and you can offer to the users the possibility to create everything you want everyone and the system of factories is untenable what you already exist Ence is on

uh foreign [Music] [Music] already existing

platforms and Beauty create an emergency able to create a federal platforms transactions and then we also create the possibility political factors and now I know I'm going through I hope to show you go over what you did so um let's see something let's start from the factory it's actually distrust a smart content that lets you have the possibility of your users want

and the uh SpongeBob and increase our Microsoft so this means that we can provide your own logic your your own creation water first and then have just one model to create about such as what country said corporate each other and you can customize the logic Etc and what is simple line of code glass you just provide the rest of the folder you have created and then the initial item s and initializes and so the application is in just one

that you will of course you can exercise environment if you want and what doesn't actually for us as as we all know the approximate pattern environment is in Germany [Music] belong which must be the very first very interesting still inside your personal contract and everything Holder will create a mask for

software developers must follow the rules of the pattern set so if you have something already done you cannot add it is [Music] the Earth still the design of yours so it is that that fear assignments bye if you have to score a variable

as 4 and API here's my contact you have to put the number of your [Music] use the length of the Interior um the internet value is third surprise our goals will stay in the third two eyes and Ash for example so you are not forced to use the passive storage model and exercise studies in the end result you can't just say ing the source of

your own address to a random number what is this other word for example of course anymore three variables inside the cardinality storage numbers thing so he's [Music] [Music] just a really big number because so it is extremely secure that you are

not you will not change it and if this is of course the so this is the case you don't follow me if you have to follow your personality I know that this is a little change but it really reduces reason why and so everything is my contact has before that function that assess any kind of call and what is the general purpose portion has any other

parts of us storage of the source and music to technical together to call you the logic logic so we [Music] have to report just kidding this is not contact every time which is extremely and so the console appearingly your platform is

this side you know so every time you create a platform and most wanted a model the models because the ice I'm taking it in the performance everyone knows that when you create a smart contact me and pass some information at Construction

and you cannot do it because you follow the contract directly if you can easily excuse me into the entire time this is because when you say there's one contract inside the video watching the construct of method is not flowed anymore so if you've created the the respect your climate when you have deployed it was for example

uh related care about element which keys that emotions and addressed this is my totally to the Factory and then initialize it why or how about a bunch of people so through the factory about this funding and this is lazy about what happened in China logically

listen to initialize yourself foreign either you just think this is kind of the transportation and the listening to come from the

island twice they are also handed after that as we need what are the mattresses for example because [Music] Village called the relay Seasons patterns for at first for the first time because that will be different because the employer of the contract and when what is

the heart of your model we can do something special into the model and song for example if you're a structure that you are I'm also to do anything you can have several smart contracts communicating each other as something must be executed or set in a specific smart contract only by another specific smart contract so such the subject is authorized for is used just to check to verify if the caller is the one that can

sets data or edit or execute something and what this contains who is the subject that that calls me where is the location where these uh where this call is made for example there could be for example a smart contractor access checker that receives this call and say okay who's calling me at what address what method bytes for selector is just the selector of the function with which data with which ethereum value provided for example if a call is payable you can you can set your logic easily write this

like this let's see a little bunch of code also this code is overrideable so you can provide your own logic or you can take the logic as is but you can have um you you can have a kind of uh um Cascade call of the um of the subject of the authorization verification so for example you can use the classic code and just provide something for the uh to delegate the the control to other smart contracts or whatever and if the control passes it's just a Boolean are you able to do this

true or false and this and this lets you create complex structures of access through your smart contracts let's see if we have something more okay no another future of the factory that we create is this uh the deployed event that means for example that in your own application you don't if if your application lets you create several clones of your models you have to index them into your front end for example and you just need to know the address of the

factory you created that contains the models and then using for example the deployed event to collect all the created clone of the the Clone versions of your model so this means that the factory is a beacon no no uh more censorship inside the front end because if you just check your the smart contract directly you have access to all data and this is extremely important so other data could be for example who is the deployer of that model so that cloned model so this means that who is the one that click on the deploy button and

create the factory and or for example could be the model address so let just let me know what is the starting model of this Factory so people can for example on etherscan have access to the entire code uh another future could be the way to know how the deploying data are made how to pack the bytes of the deploying data that could be because of of course bytes can contain anything as we know so how can we be sure uh on how we need to uh encode the data inside the deploy method

simply by using for example a specific metadata inside yours so you can provide for example an urea containing a just a little piece of JavaScript code the ledge help that just helps you to correctly pack the deploying the initialization data for your application for example and you can provide it in two ways the static way so for example providing a link on epfs as we already know or build them dynamically in fact we created the dynamic metadata and provided for you in order to let you create the metadata dynamically based on

context if you want and I'm going to show you this Dynamic metadata Dynamic metadata capable element is just an interface that implements the lazy unit capable element so you could have a normal model or model provided with metadata that can contain as I said for example the data used for creating or just providing information about your factory and your model Etc and it just as classic method Yuri and plane urid what this means what is the

difference between between them Yuri can contain a Yuri of course dynamically created for example providing the entire metadata not just a link but the entire bunch of data encoded in base64. so all the logic we provide is just for example here we have the renderer which is just a method that you can feel with your own logic to write down your Json and then encode it in base64 and provide it as is so no more centralized links anymore everything is on data and the resolver

does the magic for you I want to take a look to the Yuri resolver so if when you create a Yuri when you sorry when you ask for a Yuri the internal method just calls the Yuri resolver you provided and the Euro resolver we created a general purpose version just try to resolve it calling the renderer you wrote so if it has success it will the gives back the it will give back the the rendered Yuri or if if the the operation does don't have success because for example there

is an error in the data past or you don't have a renderer anymore you can just pass the play new result maybe you choose you choose to do not have a dynamic metadata but just a classic Yuri where to grab the metadata so let's take a closer look at the factory the factory just manages a single model to clone but as I said you can you can provided your own version of the factory basing on the skeleton and just use the lazy unit method to create your own models cooperating each other and but this is just one Factory what if for

example your model need needs to be updated you can specify a specific specific Access Control in order to be able to change the model but as we said at start it could be dangerous so the best way is to seal everything and just use a system that versions your factories so you have Factor Factory versions one using model version one factory version version 2 using another model or another way to create etc etc etc how to manage this using always the same concept of one just one address to to

save in your front end let's say and grab all the data directly from the chain we created the concept of factory of factories so once you create your model you create your factory then you can call the factory of factories just to index all the factories linked to that project for example so you you can create a new Factory passing the bytecode the factory of factories will create the factory and store it into its storage and you can and you can as in the in the in the in the way using by the factory just index them

if you need to update your factory you don't have to update that factory but you can create an ad a new Factory to that to the attaching deed to the the previous one so when you create a factory or a bunch of factories every Factory will have a list a position in the list of the factory of factories and then you can use that position just to add another Factory to that list so this means that you don't have to save the Factory address anymore you just need to save the factory or factories of that of uh just the factory or Factory address which is

a Singleton created for you and you can use it and just using the list positions we provided you when you create your own Factory through the factory added event just to have all the factories of of your application and just use them to list all the models created with with versioning and it sees extremely important important and uh totally censorship resistant if you think about it and for example you can provide provide also a way because of the factories could be just give me a second could be payable for example you can

also provide the logic to let people pay to clone your own models so you can create your own business on it if you want and if you if you can use the factory or factories environment you can also have a lot of apis just to help you to set up your economic logic so everything is already done we as I said put the mat and you put your logic put the love as we said okay uh so

let's go back to the slides again so has in the web 2 platforms the platform provides you everything provides you a set of rule you must follow to create the applications and people can use these factories these platforms to build their own entities basing on the rules that you provided and this is with their own governance and their own economies for example and this means that creating a platform is means creating a nation having their own businesses so you

provide the generic rules that the all the all the all the entities must follow okay the fundamentals and then and then all your the application built on them will automatically follow that presets choices you provided to the users so this means that like in the countries this worker this is how countries works if you think about it so the platform could be it could be a nation if you think or as we said a non-nation uh to talk about non-nations we invite you to uh stay tuned on our speech by aletoshi tomorrow in the next session uh

tomorrow during a its session so thank you very much I don't know if you have any question no questions okay so we can take for example a closer look to the code of the lazy unit how the legend and the initializer work so for example when I deploy a contract using the the the deploy method of a factory the factory internally calls the initializer which is a library what the initializer does it simply calls the Creator Library

let's take a closer look to the Creator the Creator just uses the general purpose proxy so to the Creator you provide the source address of its byte code so for example if you if if it is the first time to create uh you creating a a model through a a cloned application through your model it could be also the first time your source code is created so you can provide at the same time the the address of the model of its bytecode just using the bytes data if the bytes data is an address it must be used to be to to initialize the general purpose

proxy to create it or you can just use the create low level API into a solidity assembly to create the source at start and then use it to create a general purpose proxy passing the source code also using uh um the also passing ethers to create it so as we said the in the factory calls the initializer the initializer called The Creator that creates your clone model that we call Destination and then the logic just call the legend method through to the calling your destination

so this means that you don't have to use a Constructor inside your model but just implement the lazy unit method that we show we I showed you before which is the one of the lazy unit capable element just to create and in analyze your application by cloning it and without using without directly deploying it what this means that the created method is is called is raised by the by the factory itself so you must just uh uh stay tuned for the um for the for the events of the factory

and you can for example fill up your front end directly without saving any time all the addresses of the cloned applications that people clones that people clone and this could be a huge help for filling all the the entire the entire the entire logic okay so let's see what we can offer to the legend capable element for example it supports the RC it supports DFC 165 that lets you for example declare or the methods provided by your model so you can check for example if your model like

for example uh as an a specific method the supports interface will tell you you can provide the logic to set the host who has special permissions inside your uh your models through using another just a user access control so no no no one can must be able to change the host but only the authorized smart contracts or authorizes addresses if any and the subject it's authorized for will be will uh will provide the logic for you and for this reason we created also a modifier called

authorized only the just you get that any method can use of your model just to provide the logic to check if the subject that is calling the msg.sender is authorized to do that call for you just passing the data of the call so it is the msg.sender the signature of the method you're calling the entire payload of data and if any the ethereum that you provided okay let's see what can just we also provided a method to be compatible in a really easy way with

optimism and EDM and classic mainnet ethereum what is the only difference actually between optimism and and and ethereum the way you uh retrieve the block number of the main net because when you have to to take the block number on um ethereum you just call the block DOT number uh API on evm but or we already we know that everyone knows that in Optimus this could be this could be not possible because because if you call block that number you are calling the number of the of the optimism chain but if you are you you need on optimism the

block number on of um of the main mainnet you can just use the optimism API optimism just provides you the address to call to retrieve the L1 block number so this can help you to write a simple logic just to retrieve the block numbers from the optimism to uh from ethereum net to a optimism is mainnet L1 let's say uh so let's okay let's take a closer look on the resolver of dynamic queries so Dynamic query resolver is must be

um just a Singleton contract so not not be necessary to deploy that can call the resolver is n if any or just uh retrieve you the plane Theory and the logic of the resolver that the the renderer of the logic could be written directly by you and it returns just a string containing the metadata of your uh of your logic and to let you be uh easiest the more the easiest as possible to create your own metadata we just provided to you a bunch of utilities that can you you can use for

example let's see if I found something here for example to convert and address from byte address to string in order to provide it inside your metadata or numbers for example so you have a number and have to to to render it as string we just provide you the entire logic you can use to to do that or for example the conversion to base to base64 so when you have to create a dynamic metadata you just write your Json let's say convert it into base64 and then um and and and then attach just the the the

the base64 data that you can use to transform it in a local Yuri so with all this stuff you just call in into your front end just query the the the the link that we provided but the the response is already into the link so it just render itself without calling any kind of external source so this is a hundred percent a censorship resistance okay guys I think that for me is enough if you have any question we can I can respond you

no one okay I think