Aztec Sandbox Quickstart Tutorial

Aztec Network Talks · March 2024 · 9:06

Aztec Labs developer relations engineer José Pedro Sousa presents a quickstart tutorial for building in the Aztec Sandbox, a local developer testnet version of Aztec's privacy-first L2 on Ethereum. The tutorial helps developers set up the environment and start writing private smart contracts.

Speakers

Topics

From Aztec Network Talks, hosted by Aztec Network.

Transcript

Aztec is a privacy focused L2 on ethereum it relies quite heavily on zero knowledge proofs to allow for privacy on a truly decentralized Network it allows you to execute private and public transactions and St public and private State there are three little steps to becoming a privacy developer first of all Aztec puts a smile on that face second you install the Aztec sandbox and third we go on with our lives so step one put a smile on that face we know a lot about ZK so we want to make it even harder right because it serves our egos okay I'm joking we want

to build something amazing for the real life and something you will deliver so you install the send box where where do you sign in right well one of our main focus was to give developers a local test net as soon as possible so we came up with the atic sandbox the Astic sandbox is a local development Network that really doesn't prove anything but allows you to start developing your own logic and be ready for the upcoming test net and Main net if you have Docker and node install you can basically just follow this Meme and go on with your life and just start hacking just remember that five hours

debugging can save you five minutes reading docs so make your choices so hopping on my terminal uh keep in mind I'm focusing on Linux and mic OS if you have Windows you can either use WSL or you can follow the manual instructions at docs. aztec. Network in any case you need to have Docker installed so if you don't have Docker installed you can just copy and paste this command and this will install Docker for you uh if you don't know if you have Docker you can just go and run Docker SL version that will give you something you also need node installed if you don't have node installed I recommend to

install it via NVM which is a really cool uh versioning manager so you can also run just this command and it will install NVM in my case it's already installed and then from then on you can just go and run NVM install node and that will give you the latest version of node once you have these two very common dependencies you can just run npm create ASC app and that's that's about it uh you can choose just a contract example which in this case is just a token example or you can choose a b plate project that

comes with a front end uh you can have a react app which is a very common front content framework are the very barebones vanilla HTML typescript app and that like that so I'm going to choose that going to give it a name which will be e Global and it will be cloning my box and replacing my paths and then ask me if I want to install the atic sandbox I will say yes please do so this will take a while so I'm going to cut it here so after a few minutes it just asks you if you want to start the sandbox I'm going to say yes but in the meantime I can actually go and see my my code right

so I can go and just open my code editor so here we have the example as you can see it's a typescript project uses webpack so there's a webpack configuration that should work kind of out of the box for development you have a contract uh contract is pretty basic nothing too fancy uh just simply has a storage with a number and you can set and get that number so then there's this configuration file which is basically your connection to your own pxc process

that is running with the sendbox together with the send boox the HTML file well you don't need to think too much about this one and then you have the logic nothing too fancy as well uh just queries some selectors and listeners and deploys a contract basically it doesn't do more than that and then there you have two buttons one to set a number and the other one to get a number and yeah that comes with the an input as well then we have some tests these are front end tests so they run the wall end to

endend flow on a headless browser to check that everything is correct so now you probably want to see this working so I'm going to open a new terminal and to install my dependencies with yarn this can take a little bit as well let's wait so now I have my dependencies installed so I can just open Package Json to see what scripts do I have um the most relevant here I guess is the Run Dev which in turn runs prep it also compiles your contract here and generates typescript bindings

those are the artifacts that uh will be very very handy so let's run this going to go yarn Dev and see what happens so it will first clean in this case there's nothing to clean and then compile my contract which is here and also generate the typescript artifacts and then start the browser so before we go on the browser I'm going to just show you what exactly is this artifacts so you can see here this is is basically your contract but with the typescript interface so it allows you to

call for example deploy this contract or deploy this contract with a public key or with options and also all the methods that you can have it already gives you what types do you need to pass into them so this is very very useful uh interface so as you can see we didn't go crazy with styling here uh it's just a basic HT ml box that you can click on and be happy with that and but that box will deploy a contract as you can see here uh it has an address so you can then get the number this is a random number that is set with on the

Constructor you can set that number that will set the transaction to the network and privately set that number and you can get it and I mean if you're bored you can do this many times I don't know it's up to you so now you have a project you want to expand it so you can visit dos. aztec. Network and here you will be able to learn anything from our road map to our Core Concepts like high level explanations there are some deep Dives here as well some tutorials on things

that can be very useful such as writing a token contract or a token Bridge uh you also have reference material on the sandbox the smart contracts and the astec JS this is very handy if you want to write contracts uh and you want to know for example what methods can you call what do you have available and and here the Aztec JS is definitely if you want to build an app and you want to interact with it you also have some guides here and for the sandbox basically how to control the sandbox run more than one pxe uh this could be handy as well and that's basically it you should be able

to start from here and if you need any help you can always ping us on the Aztec um e Global Channel and we will do our best to help you happy hacking