Solana Bootcamp - Episode 1 - Introduction to Solana
Solana2023-07-25
solana#learn solana development#sol#solana crash course#blockchain bootcamp#soldev#solana course#intro to solana#intro to web3js#solana web3#solana javascript#solana typescript#mint nfts on solana#create tokens on solana#how does solana work
35K views|1 years ago
💫 Short Summary
The video provides a detailed overview of the Salana blockchain, explaining its technical advantages and operation with validators, accounts, and transactions. It covers the process of interacting with the blockchain, creating transactions, minting tokens, and building complex transactions. The video also delves into the creation of SPL tokens, associated metadata, and NFT collections using the Metaplex SDK. It emphasizes the importance of understanding concepts like mint accounts, freeze authorities, and metadata accounts for efficient token creation. The workshop concludes with a demonstration of creating NFTs and customizing metadata, encouraging viewers to experiment with building pirate ship NFT collections.
✨ Highlights
📊 Transcript
✦
Overview of Salana blockchain and its technical advantages.
00:23Salana features fast confirmation times and low transaction fees.
Network operates with validators, leaders, and transaction blocks globally.
Salana allows for parallel execution of transactions with stateless design and Proof of History.
Interactions with the blockchain using JavaScript and TypeScript highlighted, emphasizing speed, efficiency, and global consensus.
✦
Overview of Salana blockchain account system.
03:32Accounts hold Soul tokens and data, identified by unique 256-bit addresses.
Anyone can credit tokens to accounts, but only owners can debit tokens or modify data.
Accounts can have an executable flag for containing programs.
Programs on Salana are deployed to the blockchain for decentralized execution and have specific instructions and processing capabilities.
✦
Overview of Salana programming language and platform.
07:08Programs are primarily written in Rust but can also utilize C, C++, Python, and JavaScript.
Accounts on Salana are stateless and can only read and write data to other accounts, not their own.
Each account holds a SOL token balance.
Programs can execute instructions involving multiple accounts and benefit from parallel execution on the blockchain for high performance.
✦
Overview of Salana blockchain transactions and instructions.
10:57Programs invoke instructions in transactions that must be atomic and signed.
Clients build instructions, put them into transactions, and send them to PC clients and voting validators.
Validators use a runtime to execute instructions, calling specific programs for tasks like incrementing a counter.
The video demonstrates the basics of Salana blockchain and how to use and build transactions.
✦
Creating a simple transaction using JavaScript and TypeScript on the Solana blockchain.
13:17Importing functions and values, creating asynchronous functions, logging out payer address key pairs.
Checking balances, requesting airdrops for low balances, generating random key pairs.
Creating accounts on chain, allocating space on the blockchain, and paying rent for space on the Solana blockchain.
Rent requires two years of payment upfront and understanding these concepts is crucial for working with the Solana blockchain.
✦
Overview of Validators and Data Maintenance on Solana Blockchain:
16:25Validators are incentivized to store data on the blockchain by paying a fee upfront.
The Solana Web3.js library offers a function for rent exemptions.
Creating an account on the Solana blockchain requires providing owner address and space allocation details.
Transactions on Solana necessitate recent block hash values and building transactions with instructions, ensuring compatibility with newer versions.
✦
Creating and signing a transaction on the blockchain involves deducting Soul tokens and requires at least one signature.
19:30The transaction process includes allocating space, creating an account on the chain, and signing the transaction with the key payer.
After sending the transaction to the blockchain, logging is done for simplicity.
Transaction completion is verified on the Salana Explorer, displaying common blockchain information like timestamp, signature value, total transaction fee, and accounts involved.
Each signature costs 5K Lamport ports, with detailed account balances shown.
✦
The process of executing a transaction in the video segment.
22:29Two signatures are required for the transaction, space on the chain needs to be allocated, funds transferred, and complex transactions with multiple instructions built.
Steps include generating key pairs, setting space to zero bytes, executing transfers between accounts, and creating instructions for transactions.
Importance of understanding the process and differences in building simple versus complex transactions is highlighted.
Proper execution and allocation of resources on the chain are emphasized.
✦
Overview of building transactions for the Solana blockchain.
25:53Emphasis on executing instructions automatically and maintaining data integrity.
Process of signing and sending transactions to the blockchain.
Role of RPC in forwarding transactions to validators.
Creation of mints by the token program and ownership relationship via associated token accounts.
✦
Creating SPL tokens on the Solana blockchain.
28:50Ownership of Associated tokens and metadata explained.
Use of Metaplex metadata program for adding token information.
Creation of SPL tokens through Solana transactions and minting.
Demonstration of creating an SPL token with metadata using TypeScript code.
✦
Creating a Mint Account for Tokens.
32:30The process involves allocating space, defining mint and freeze authorities, and initializing the mint account.
Program Derived Address (PDA) is used for storing token metadata on the blockchain.
The mint authority controls token minting, while the freeze authority can prevent additional tokens from being minted.
The metadata account is owned by the token metadata program, denoted by meta QB.
✦
The process of creating a metadata account on the chain through deriving a PDA from a metadata program.
36:25The metadata V3 instruction is used with necessary values and addresses set to zero for simplicity.
Instructions are grouped into a single transaction with a helper function, signed, and sent to the blockchain.
Upon successful completion, various addresses are logged out, including payer, wallet, mint, and metadata PDA.
Additional accounts, such as the mint and System Program token metadata accounts, are included in the transaction, and the data passed along can be viewed in the instructions.
✦
Creating an Associated Token Account (ATA) is a key part of the token minting process.
40:35The ATA is owned by the user and holds ownership over the minted tokens.
A helper function in the SPL token SDK simplifies the process of getting or creating the ATA by deriving a PDA address.
The ATA is linked to the payer of the transaction and the owner of the tokens, which can be the same or different entities.
This streamlined process allows developers to efficiently create and distribute tokens.
✦
Process of minting tokens under the SPL token program.
42:32Importance of decimals in token creation for accuracy.
Demonstrating minting tokens to an associate token account and logging transaction details.
Role of mint and freeze authority in token creation and supply.
Demonstration of minting additional tokens and viewing updated token balances on Explorer URL.
✦
Updating Token Metadata Process.
46:01Ability to update metadata as long as the token is not frozen.
Process involves creating an update instruction, building a transaction, and signing it with the payer's authority.
Successful execution on the blockchain with updated metadata reflected in the Explorer.
Emphasizes the ease of updating metadata directly on-chain and importance of proper error handling.
✦
The process of minting new SPL tokens on the Solana blockchain involves creating a new account, initializing it as a token mint, creating a metadata account for that mint, and having an Associated token account that holds a balance of the specific token.
49:43NFTs on Solana are actually SPL tokens with unique properties, such as zero decimal places, a supply of one, and customizable metadata.
NFTs can be grouped into collections, with each collection having a master Edition account to store specific metadata.
The video segment details the process of creating NFT collections and NFTs on Solana.
✦
Creating NFTs with Metaplex SDK on Solana blockchain.
53:23Explanation of minting process, including creating metadata, minting images, and using decentralized storage providers like IPFS.
Metaplex SDK offers helper functions and simplifies minting process.
Details on setting up metadata, symbols, names, and seller fees are covered.
Emphasis on ease of use of Metaplex SDK for minting NFTs and importance of royalties in NFT marketplaces.
✦
Setting a 5% royalty on all sales with specified royalty address.
55:21NFT set as mutable for metadata updates.
Logging out NFT object and signature for transaction viewing on the Explorer.
Showcasing uploading data to R weave using a bundler, with details about NFT data object and associated metadata.
Automatic detection of creator and seller fee, along with additional information about NFT.
✦
Creating NFTs on the Solana blockchain involves setting metadata like name, symbol, and image.
59:24NFTs on Solana are SPL tokens with unique properties, zero decimal places, and a supply of one.
Metadata can be highly customized for NFTs on Solana.
Mint accounts store data for a token mint, while associated token accounts hold user balances.
The challenge is to create a personalized NFT collection in the workshop.
✦
Workshop on building 32 pirate ships with images and IPFS/RWE storage.
01:02:22Code repository includes example links and references for additional information.
Three SPL tokens for gold, rum, and cannons are generated.
Viewers are appreciated for watching and encouraged to have learned valuable information.
00:00[Music]
00:08hello everyone gmgm I'm Nick from the
00:10salana foundation devell team and
00:12welcome to this salana Workshop
00:14throughout this video and this Workshop
00:15we're going to be going over the basics
00:17of the salana blockchain how it works
00:19and how to actually get started with
00:21developing on salana we're going to talk
00:23about things like the salana programming
00:25model as well as how to actually
00:27interact using JavaScript and typescript
00:29how to interact with the blockchain and
00:31perform some of the super common actions
00:33that you'll actually be doing when you
00:35are developing any applications on
00:37salana so let's get
00:38started a brief overview of the agenda
00:41the first thing we're going to talk
00:42about is the salana network broad like
00:44highlevel overview including the
00:46technical advantages and a broad just
00:48Network overview of how Salon actually
00:50works so at a high level the two big
00:53technical advantages of salana is you
00:54have really fast confirmation times
00:56especially compared to other blockchains
00:59as a salana transaction can be validated
01:01by the entire network in about 400
01:03milliseconds which is significantly
01:05faster than most other blockchains so
01:07with every single transaction you also
01:09have these low transaction fees which a
01:12single transaction is usually about
01:145,000 lamp ports per transaction
01:16signature per signature on a transaction
01:19which we'll go talk about more in depth
01:20of what those uh specific terminologies
01:23actually mean throughout the duration of
01:25this video and all of this is actually
01:27while maintaining uh valid consensus
01:29through about 25,000 plus voting
01:31validators scattered all around the
01:33world so it's a very globally
01:34distributed Network run by entities and
01:37and individuals from around the world so
01:39the next thing we'll get into is a broad
01:41overview of how the salana network
01:42actually works so at a high level
01:44there's a validator leader and this
01:46leader is going to receive all the
01:48transactions uh throughout the entire
01:50blockchain it's going to take all these
01:51transactions that get created on the
01:53front ends and the the decentralized
01:55applications that you're used to
01:56interacting with blockchains with and
01:59the leader going to take all these
02:00transactions it's going to pack them in
02:01the blocks these blocks are then going
02:03to get propagated throughout the entire
02:04salana network again those 200 or 2500
02:07voting validators throughout the entire
02:09world uh using a piece of code called
02:12turbine and turbine is just the the
02:14block propagation portion of the salana
02:16protocol and these transaction blocks
02:19just get sent around the world and one
02:21of the interesting things about salana
02:23is that all these transactions can
02:25actually be executed in a parallel
02:27fashion because of the way that salana
02:29is designed a portion of that is because
02:31every single transaction on salana is
02:33actually stateless so a specific
02:35transaction doesn't maintain its own
02:37State its own data it's interacting with
02:39accounts that are actually storing those
02:40bits of data which we'll talk more about
02:42the accounts here in a bit but every
02:44single transaction is going to read and
02:45write to different accounts on the salon
02:47of blockchain and because all of those
02:49reads and writes get processed
02:50differently on the blockchain it allows
02:52all of these transactions to be executed
02:55very very fast which again leads to that
02:57really low confirmation time and and the
02:59really fast block propagation throughout
03:01the entire network and all of this uses
03:04uh this concept called proof of History
03:06which is one of the innovations that
03:07allows salana to actually be so fast as
03:10a blockchain so just some of the key
03:12takeaways is that salana has really fast
03:14confirmation times low transaction fees
03:16it executes programs in parallel and and
03:19thus uh transactions in parallel as well
03:22and it's ideal for high performance
03:23applications because of all these
03:25features next we're going to talk about
03:27the general programming model on the a
03:30blockchain so the first thing to
03:32understand is accounts and I mentioned
03:33accounts earlier and accounts are one of
03:36the key portions of the Sal blockchain
03:38basically on salana everything is an
03:40account you can kind of think of
03:42accounts like files on an operating
03:43system especially if you're used to a
03:45Linux based operating system every
03:47single program and every single bit of
03:49data is a file very similar in salana
03:51everything's an account accounts are
03:53unique 256-bit addresses they all hold
03:57some balance of Soul which is the the
03:59native token on the salana blockchain
04:01they can also store arbitrary data just
04:04in the form of raw bytes and the data
04:07storage that that actual data storage is
04:10paid for in what we call rent and we'll
04:12talk more about rent here in a moment
04:15now some of the key things to understand
04:16about accounts is that anyone can credit
04:18the soul token to an account and anyone
04:20can read data from the account in a
04:22permissionless fashion but on the flip
04:24side only the owners of an account can
04:26actually debit Soul or remove a soul
04:29balance from it or actually modify the
04:30underlying data of an account and that's
04:32really what you want because that will
04:34inherently make it so you can have uh
04:35security over who actually owns the data
04:38and you can have ownership verification
04:40so we can look at the accounts in its
04:42raw form and you can see there's a
04:44couple of key uh key pieces of data that
04:46we have here we have the key which is
04:48basically the address of the account you
04:50can think of this of the like your your
04:52public address that you might be used to
04:54seeing on various blockchains you have
04:56the lamp ports which is the actual total
04:59balance
05:00lamp ports are the smallest unit of
05:02value for a the native Soul token so in
05:07a lamp port or rather one soul is about
05:10a billion lamp ports and a accounts
05:14actually store the number of lamp ports
05:16that that account is has ownership over
05:19and then you have the actual data that's
05:20stored within the account and again this
05:22is just the raw byes stored in the form
05:24of an unsigned integer or a u8 array and
05:28again those are just the byes that are
05:30actually stored on the blockchain itself
05:32and then there's this is executable
05:34Boolean flag that every account has and
05:36basically this this just signifies if
05:39the specific account that you're
05:40interacting with is a program or not if
05:42executable is true it's a program if
05:45it's false it's just a data account and
05:47lastly there is a owner value every
05:50single account has an owner and only the
05:52program owner of that account actually
05:54has the ability to update the data
05:57that's in that account now that we've
05:59mentioned programs let's go ahead and
06:00talk about specifics about them on other
06:03blockchains programs might be called
06:04smart contracts but on salana they're
06:06called programs and basically these are
06:09the the pieces of code that you can
06:10actually deploy to the blockchain in a
06:12decentralized fashion that are actually
06:13going to execute some amount of
06:15instructions and some sort of processing
06:17on the blockchain itself and
06:19specifically for salana programs is that
06:22they're basically a special type of
06:23account like I mentioned before they
06:24have that executable flag is a is a true
06:27F A True Value which lets the salana
06:30runtime know that it is actually a
06:32program uh they actually the data that's
06:35stored within that specific account is
06:37ebpf bite code which is the Berkeley
06:39packet filter bite code and programs are
06:42typically written in Rust whether it's
06:44native or one of the salana rust
06:47Frameworks that are out there you can
06:49also write programs in C and C++ and
06:51there's a couple of helper libraries out
06:53there for writing programs in Python and
06:55then soon other uh common programming
06:57languages but for or things like Python
07:00and JavaScript any programs that are
07:02written in those typically just get
07:03transpiled down into their rust code
07:06equivalents so some of the key things
07:08about programs on salana is that every
07:10program is stateless they actually can
07:12only read and write data to other
07:14accounts so they can never actually
07:16write data to their own account and this
07:18is actually one of the things that
07:19allows programs to be executed in
07:21parallel which again leads to the speed
07:24improvements that the salon of
07:25blockchain has and like we talked about
07:27for General accounts everying sing Le
07:29account has an owner value and only the
07:31owner can update the account so if
07:33you're writing a program you can make
07:34any program you write be the owner of
07:37any other account as long as you have
07:38the appropriate permissions to do so and
07:40only your program will be able to
07:42actually write data to those accounts
07:45all programs execute instructions which
07:47we'll talk more about here in a bit and
07:49instructions are basically the uh bits
07:51of information that you're trying to ask
07:53the salana runtime or a specific program
07:55to actually execute programs can all
07:58send instructions to each other using uh
08:00something called cross program
08:02invocation or CPI for short or you can
08:05have uh instructions be built on a front
08:08end like JavaScript or typescript on a
08:10website or a decentralized app that can
08:13then get sent to the salon of runtime
08:14for
08:15execution so the key takeaways about
08:17accounts and program is that everything
08:19on salana is an account all accounts
08:21hold a soul token balance in the form of
08:23lamp ports accounts can store arbitrary
08:26data uh accounts can also be also store
08:28executable programs themselves and
08:30accounts are all passed into programs
08:32allowing for for parallel
08:35execution now we're going to talk about
08:36some of the specifics about salana
08:38program instructions so you can see the
08:41raw form of an instruction here where
08:43you have the program ID of the program
08:45that's actually executing the
08:47instruction then you have a list of an
08:49array of keys and these are all the
08:51accounts that are actually involved with
08:53executing a particular instruction and
08:56this is one of the things that allows
08:57the salon runtime to be very performant
09:00is that every every address or every
09:03account that gets touched inside of a
09:04transaction or inside of an instruction
09:06specifically is that you have to provide
09:08all of those values all those addresses
09:10within the instruction and this
09:12technique actually is one of the things
09:13that allows for the salana blockchain
09:15and the salana of runtime to have this
09:18parallel
09:19execution and then lastly you have uh
09:22some amount of data in the form of the
09:24raw bytes that are actually being sent
09:27over the wire to the program that you're
09:28trying interact with that's that program
09:30ID and then you take all of these
09:33instructions and you can have multiple
09:34instructions and you bundle those
09:36together inside of a transaction and a
09:38transaction is the thing that you're
09:40actually sending to the rpcs or sending
09:43to the validators on the salant network
09:45which then get processed through that
09:47leader process and the the turbine uh
09:50execution or the turbine block
09:52propagation throughout the entire
09:53network here you can see a transaction
09:55in its raw form and you have some key
09:57pieces of information here we have an
10:00array of instructions just the the list
10:02of instructions that this transaction is
10:03trying to execute you have a recent
10:06block has which is used for D
10:08duplication of transactions and this
10:10allows for some of the speed
10:11improvements as well as some security
10:13features you have the fee payer address
10:15of whichever account is actually going
10:17to be paying the gas fees for your
10:20particular transaction so all those uh
10:22small transaction fees that you get on
10:24the network and then you have the actual
10:26an array of all of the signers so with
10:29every transaction anytime an account is
10:32updating data whether you're updating
10:35the actual data itself or if you are uh
10:37debiting lorts or soul from an account
10:41uh that public key is required to
10:43actually sign a transaction and this
10:44allows for the cryptographic
10:46verification and signature verification
10:48on the blockchain and we just include
10:51all of those signatures in the form of
10:52the raw bytes inside of every
10:55transaction so the key takeaways on
10:57transactions and instructions is that
10:59programs invoke instructions
11:01instructions are sent via transaction
11:03and transactions are required to be
11:05Atomic and transactions all must be
11:08signed so now we'll kind of tie it all
11:10together via the life cycle of a
11:11transaction so we'll start from the
11:14perspective of a client so you have a
11:16decentralized application and you're
11:17building transactions for your users so
11:20the the client will actually build the
11:22instructions which then get that get uh
11:25put inside of a transaction the
11:27transaction gets sent to the PC clients
11:30which then forwards all of the
11:32transactions to the voting validators
11:34the validators will actually use the
11:36salon of runtime to uh enable the
11:39runtime to actually execute each of the
11:41instructions within every
11:43transaction and then each of those
11:46instructions will call to a specific
11:48program to actually execute whatever
11:50that program's code is trying to do so
11:52this program is just say incrementing a
11:54counter and it's just going to increment
11:56it up by one so that's the broad life
11:59cycle of a transaction on the salana
12:01blockchain so now that we've talked
12:03about the basics of the salon blockchain
12:05and how it works we're going to go
12:06through some demos of how to actually
12:08use and build Salon transactions so the
12:11first thing is we're going to be going
12:13through this example code repo uh the
12:15link will be available in the
12:16description in the show notes and take a
12:18look through the readme it kind of
12:20describes how this uh specific uh
12:22section of the repo is laid out and what
12:24each of the files are doing um but the
12:26first thing to note is that we're
12:28connected to the salana devet so you can
12:30see here I have the salana CLI installed
12:33on my computer and we're actually
12:35connected to this devnet RPC and I also
12:38have a local key pair at this file path
12:42which we'll talk more about this in a
12:43moment and you can see that this is the
12:45actual address for my key pair is this
12:47Nick b1d and ends with uh rexd and then
12:52this particular uh devet account
12:55actually has a soul token balance of
12:57about 240 something uh actual Soul
13:00tokens so because we're actually going
13:03to be executing transactions on the
13:05salana blockchain specifically the
13:07devnet portion of the blockchain is
13:09we're going to actually have to be able
13:10to pay for the fees for all of those
13:13transactions so you need to make sure
13:15you have some amount of balance in there
13:17so the first script we're going to go
13:18through is this uh script inside of the
13:20scripts folder script number one simple
13:23transaction and we're going to go
13:24through the process of actually creating
13:26a very simple transaction just so you
13:28can understand the basics of how it
13:30actually works with using uh typescript
13:32and JavaScript this entire section of
13:35the repo is actually laid out in all
13:37typescript so if you're not familiar
13:38with typescript don't worry you can do
13:40all the same things with vanilla
13:41JavaScript it'll all work just the
13:44same so the first thing we're doing here
13:46is we're actually doing some pretty
13:47standard Imports we're importing some
13:49functions and and values from the salana
13:52web 3js as well as we're importing some
13:55uh helper functions that are stored
13:56locally within this repo and one of
13:59those helper functions or or one of
14:00these variables that we're importing is
14:02this payer uh payer address and I'm
14:05actually taking my local key paay file
14:08this Json file id. Json I'm loading that
14:11in using JavaScript so that way I can
14:13use this on my JavaScript application
14:15front end and again that's just using
14:17some helper functions within this repo
14:19you don't really need to worry too much
14:20about that that's not really salanos
14:23specific now the first thing we we're
14:25doing is we're actually creating an
14:26asynchronous function because we are
14:28going to do some async await uh
14:29functionality within JavaScript and
14:31we're actually just going to log out our
14:33payer address key pair to the console
14:35just so you can show just so I can show
14:37that that is actually the the same
14:38address that I just showed then we're
14:41going to actually do an async of weight
14:43and we're going to get the balance of
14:44this key pair and again you should see
14:46the same values here that we have for
14:48this address and this balance and then
14:51specifically with this example if this
14:53particular balance has or if this
14:55particular address has a very low
14:56balance less than one soul then we're
14:59just going to request an airdrop which
15:00is always available on devet and testnet
15:03next I'm generating a brand new fresh
15:05and random key pair to be used just to
15:08demonstrate some of the additional
15:09functionality and we're going to log out
15:11the actual address of that key pair and
15:14then finally we can actually start
15:15building our first transaction and
15:17specifically our first instruction for
15:19our first transaction so the first thing
15:22we're going to do is we're actually just
15:23going to create an account on chain and
15:26we're going to take our payer app
15:28address that we have already funded with
15:30our soul soul balance and then we're
15:32going to create that new random key pair
15:34we're going to allocate space on chain
15:37so that way we can tell the salana devet
15:38blockchain in this case we can tell the
15:41blockchain that we want this this
15:43address to exist on chain and we're
15:44going to pay that rent now I briefly
15:47mentioned what rent is before but we'll
15:48talk more details about it right now so
15:50with all the space that is required for
15:53accounts to exist on the salana
15:55blockchain you have to pay rent and this
15:57rent you're required to pay two years of
15:59rent upfront to actually store your
16:02space on the salon blockchain and this
16:04is what we call Rent exempt of paying
16:06that uh large enough balance up front
16:08anytime you're going to allocate space
16:10on the blockchain which basically this
16:12is the concept of encouraging validators
16:15to actually maintain your space and your
16:18data on the blockchain so it's just
16:20paying that fee upfront the salana web
16:223js library has a helper function called
16:25get minimum balance for rent exemptions
16:28and we're going to allocate we need to
16:30tell it how much space we're actually
16:31going to allocate in this case because
16:33we're just going to create a very simple
16:34account just to store landport balance
16:37or Soul token balance we actually don't
16:39need any space to allocate so this will
16:41be the lowest possible amount of rent
16:43that you can pay for any given account
16:46so we're going to request M the minimum
16:48balance for rent exemption of zero bytes
16:51and then we're just going to log that
16:52out to the console just to show how much
16:54uh how many lamp ports it's actually
16:55going to take to allocate this account
16:58next we we can actually build our very
16:59first instruction we're going to use the
17:01system program and we're going to create
17:02an account because like we talked about
17:04earlier is every account is owned by a
17:06program and for generic normal accounts
17:09that are just holding a balance those
17:11are all owned by the system program
17:13which the system program is baked into
17:15the salon runtime every time the
17:17validators get updated throughout the
17:20the validator life cycle that the salana
17:22runtime program will get you know
17:24periodic fixes and anything so it's it's
17:26different to uh a program that you might
17:29try to deploy as a developer but we're
17:31going to create our first account we're
17:33going to uh provide in all the required
17:35data for this particular function in
17:38this case we're saying the from address
17:40and this is the payer of our transaction
17:42fees we're going to tell it the new
17:45address that we want to allocate on
17:46chain and again we're using this
17:48randomly generated key pair and then
17:51we're going to tell it how many lamp
17:52ports we want to store in this account
17:54and we need to make sure that we are
17:55storing at least the minimum number of
17:58lamp ports for rent exemption we need to
18:00say how much space we're actually going
18:01to allocate and then the owner of this
18:03program and again we're just using the
18:05system program as the owner so we put
18:08all that into a single uh a single
18:10variable called create account
18:11instruction I EX for short and now we
18:14can actually build our very first
18:15transaction for the salana blockchain so
18:18like I talked about earlier is that
18:19every transaction is required to have a
18:21recent block has so we can actually use
18:24the blockchain and just request the
18:25recent block has and we can get that
18:27value and we can just put it inside of
18:28our transaction right before we send it
18:31to the blockchain so that's what we're
18:32doing here we're using our connection
18:34we're getting the latest block has and
18:36we're kind of doing a little bit of
18:37destructuring and just getting this
18:39block hash value and then we're going to
18:41include that inside of our
18:43transaction so in this particular
18:45example we're building a version
18:46transaction which is a a slightly newer
18:49thing on the salana blockchain but it is
18:51slowly becoming a more and more uh
18:53common standard that is accepted and is
18:56actually supported throughout the entire
18:57ecosystem system and we're going to
19:00build our transaction we're going to
19:01provide our list of instructions in this
19:03array in our case we're just doing one
19:05single instruction we're giving the
19:07recent block has that we just got from
19:09the blockchain itself and then we're
19:11saying who is paying for the
19:13transaction and then we are actually
19:15creating our transaction we're signing
19:17the transaction in every transaction
19:20because we are uh always deducting some
19:24amount or debiting some amount of Soul
19:25token from at least one account there's
19:28always required to be at least one
19:30signature so in this case because we're
19:32also allocating space and we're creating
19:34an account on chain at an address that
19:36address that key payer is also required
19:38to sign the transaction so in this case
19:40we're going to sign with our payer and
19:42our key payer and then we're going to
19:44use our connection and we're going to
19:46send that transaction to the blockchain
19:48and then we're going to do a little bit
19:49of logging just for Simplicity and for
19:52demonstration so I'll go ahead and clear
19:53my console and we'll just go ahead and
19:55run this for
19:57script
19:58so I'll go ahead and scroll back to the
19:59top so you can see all the information
20:01that we displayed and you can see our
20:02payer address is that same Nick value
20:04that I showed earlier the Nick b1d and
20:08ends with rexd you can see our total
20:10Lamport balance and then the total
20:12balance in Soul again it's about 240
20:15point something so and then you can see
20:17we generated a brand new random address
20:20using the web 3js and then we have the
20:22actual Lamport cost to allocate that
20:24space on chain for the minimum of zero
20:27bytes and then we're actually just
20:29logging out our transactions you can see
20:31kind of the data structure that we had
20:32mentioned before of how salana
20:34transactions work is we have this array
20:37of signatures which is just a a bite
20:39array and then we have our message data
20:41which has a header our static account
20:43keys and these are all the account
20:45addresses that are touched within our
20:46transaction you can see our the payer
20:49address that is actually paying for the
20:51transaction and then you can see the
20:53public key of the address that we are
20:55allocating on chain and then this uh all
20:58one's value is the system program then
21:01we have our recent block cash value
21:03again just requested from the blockchain
21:05so it doesn't really matter what that is
21:06as long as it's recent enough and then
21:08we have a list of all of our
21:10transactions or rather our instructions
21:12that we're actually sending to the
21:13blockchain itself and then you can see
21:15our transaction did complete and it
21:17completed on devet so we'll go ahead and
21:19open this on the salana Explorer and
21:22I'll also take this opportunity to kind
21:24of discuss how the salana Explorer works
21:26and try to how to actually like
21:28understand some of the information
21:29that's displayed on here so you can see
21:31in the URL here that we're on cluster
21:33devet because our transaction did
21:35actually execute on the devet and you
21:38can see some common information you
21:40might expect on a blockchain Explorer
21:42and if you're new to blockchain
21:43explorers is pretty standard information
21:45you have a timestamp you have the actual
21:47signature value which is basically just
21:50the a keyed value for the blockchain to
21:53uh index on and you have some some other
21:56sorted information you have that recent
21:58block cash that we sent you have the
22:00total transaction fee and you can see
22:02this is actually 10K lamp ports because
22:04we had two signatures you're paying 5K
22:06lamp ports per
22:08signature and then you can see all the
22:10accounts that were included within this
22:12transaction we have this Nick value this
22:14AT3 and the system program that 111 so
22:17on and you can see our post balances and
22:21who actually had the sign this
22:22transaction we had two signatures we had
22:24two signers so our Nick and the AT3 both
22:27had Des sign this transaction which is
22:29how we got our 10K Lamport fee balance
22:33or uh fee required to be paid and then
22:36you can kind of see the instructions
22:37there that were actually executed within
22:39this transaction we had our system
22:42program executed the create account
22:44instruction because that was the only
22:45instruction that we actually included
22:47within our transaction and you can see
22:49the information of what actually
22:50happened we allocated zero bytes on
22:53chain and our instruction executed
22:56successfully so now that we have a basic
22:57basic understanding of simple
22:59transactions let's go through a little
23:01bit of a more complex transaction and
23:04how to actually build those because it's
23:05a very similar process but uh there are
23:07some slight differences you have to do
23:09so uh within the repo open the script
23:12number two of complex transaction and
23:14we'll go through this now we're doing a
23:16very similar thing we're doing some of
23:18our Imports at the top we're going to uh
23:20log out a payer our payer address and a
23:23test wallet address which is uh in this
23:25case we're importing this locally with
23:27which is just going to load or generate
23:30from our local file system here kind of
23:32just some helper functions just for the
23:33demo sake but it's in this case it's
23:35just going to Dem it's just going to uh
23:37randomly generate a new key pair and
23:39then save that key pair inside of this
23:41local directory inside the dot local
23:44Keys folder you can see the test
23:45wallet's already been generated and
23:47again just a random address doesn't
23:48really matter what it is so next we're
23:51doing the same thing we're going to
23:52allocate space on chain for this new
23:55random address that we just generated
23:58and in this case we're we are also
24:00setting our space to zero so we want
24:02zero total bytes so we're going to get
24:04the minimum balance for rent exemption
24:06there and then the only difference here
24:08is we are setting our test wallet as the
24:10address that we want to generate or that
24:12we want to uh allocate on chain and in
24:16fact we're going to store an additional
24:172 million lamp ports inside of this
24:19account the next thing we're going to do
24:21is we're going to actually execute a
24:23transfer from our test account this test
24:25Wallet account and we're going to
24:27transfer it back to our um or rather
24:30we're going to transfer it from our uh
24:32payer account and we're going to send it
24:34to the test wallet so we're going to
24:36create our test wallet on chain and then
24:38we're going to transfer from our payer
24:40to our test wallet that's going to be
24:42the second instruction we're going to
24:45execute and then we're going to execute
24:47a third instruction which we're just
24:49going to transfer to a another random
24:51address it doesn't really matter what it
24:52is this is just again to demonstrate how
24:54you would build a transaction with
24:56multiple instructions
24:58and in this case uh I'm loading in this
25:00static Pub Key value which happens to be
25:03this Nick address which it doesn't have
25:05to be just happens to be just for
25:07demonstration and we're going to build a
25:09transfer instruction and then once we
25:11have our instructions built we can then
25:13uh get our recent blockcast just like we
25:15did before and we can build our version
25:17transaction just like we did before
25:20except this time we are putting in four
25:22individual instructions we're creating
25:24our test account we're transferring to
25:26our static wallet we are transferring to
25:29the test wallet and then we're
25:30transferring to the static wallet again
25:32just to demonstrate that you can do a
25:33lot of these types of things Allin one
25:35transaction because every single
25:37instruction in a transaction is executed
25:40automically and what that basically
25:42means is that every single instruction
25:45is executed in order and if any of those
25:49instructions fail the entire transaction
25:51will fail so you get a little bit of
25:53data Integrity in that way so then we're
25:55going to finally build our transaction
25:57we're going to sign it with our payer
25:58and our test wallet and then we're going
26:00to send that transaction to the
26:01blockchain and then we're going to log
26:03it out for
26:04demonstration so let's go ahead and run
26:08this
26:09script so script number two complex
26:14transaction and there we go it completed
26:16successfully again we have the exact
26:18same payer address we have this new
26:20random test wallet address that we
26:22generated and we completed successfully
26:24we logged out our Explorer
26:26URL and we can open up the Explorer and
26:29see what it looks like all right again
26:31you have a lot of the same information
26:32you have the signature address the
26:35timestamp the number of the amount of
26:37our fees that we actually paid we have
26:40our three account inputs these are going
26:42to change for every instruction that you
26:43actually execute and then you can see
26:46the list of all the instructions that
26:47we're actually executing automically
26:50inside of this transaction so that's the
26:52basic overview of actually building
26:54transactions for the salana blockchain
26:56and we'll go back through the key take
26:57ways is that applications will actually
27:00build and send transactions to an RPC
27:03the RPC is going to actually take all
27:04those transactions they're going to
27:06forward them to the rest of the network
27:07to the voting validators the validators
27:09can then execute those those
27:11transactions which are going to invoke
27:13uh programs and each of those programs
27:16has the ability to update accounts of uh
27:20accounts that they have the authority or
27:21ownership over so next we'll talk about
27:24tokens on the salon of blockchain so
27:26tokens are actually a combination of
27:29effectively three different programs on
27:31the salana blockchain there's the token
27:33program the associated token program and
27:36the metadata program token program and
27:38Associated token program or ATA for
27:40short are programs that are deployed by
27:43the salana labs organization and the
27:46metadata program one of the common ones
27:48is deployed by the metaplex foundation
27:50so these are three different programs
27:52that are built by two different entities
27:54that are used by uh almost everyone on
27:57the Sal on a blockchain now for creating
27:59a token uh the token program will do
28:02what's called create a mint so a mint is
28:05basically just an account that has uh
28:07control over some amount of token
28:08balance you can think of this like a
28:11normal government where you have like
28:12for example the United States government
28:14they have the treasury Department which
28:16runs the United States Mint and the mint
28:18is responsible for actually creating the
28:20national currency the exact same concept
28:23here is we have the token program has
28:25control over a mint which has the
28:27ability to Mint new tokens and then once
28:31tokens are minted from our mint they
28:34need to be owned by a a wallet by a user
28:37in order to actually interact with the
28:39rest of the blockchain and this is
28:41actually in the form of this unique
28:44ownership relationship via Associated
28:46token accounts where a wallet will
28:48actually own the associated token
28:50account will have authority and
28:52ownership over an Associated token
28:53account and that ATA is actually what is
28:56storing the uh Soul tokens the SPL
28:59tokens that you're actually uh used to
29:01interacting with on the blockchain and
29:03then additionally with this is the
29:05tokens can actually have metadata
29:07associated with them using something
29:09like the metaplex metadata program where
29:12you can have things like the the name of
29:14the token an image that represents it to
29:17kind of give some sort of visual bit of
29:18information for a token you can have a
29:20symbol and all of that types of
29:22information is stored within a metadata
29:25account which is owned by the metadata
29:27program which has a relationship with
29:30your tokens mint so if you wanted to do
29:33something like create an SPL token you
29:35want to create uh you know a random
29:37token for whatever your use case is you
29:40can do that by using a salana
29:43transaction and you're going to create
29:45all the instructions that you need in
29:46order to perform all these various
29:48actions on chain like creating our new
29:51account initialize that account as a
29:53mint create the associated token account
29:56and then you can actually mint token
29:57tokens from your mint into the
29:59associated token account and all of this
30:01can actually be done with a single
30:02transaction on the salana blockchain
30:05which is really cool because this
30:06composability that the salana blockchain
30:08has it means you don't actually need to
30:10deploy a new program in order to create
30:13tokens or SPL tokens so that's really
30:16cool so let's go ahead and go through
30:17that process now we'll use again our
30:19typescript uh code and our scripts here
30:22we're going to open script number three
30:24and this is actually a demonstration of
30:26how to create an SPL token a salana
30:29program Library token with metadata on
30:31the salana blockchain so pretty standard
30:34stuff at the top we're importing we're
30:36we're importing our various uh needed
30:38things and of note we are importing some
30:41variables and values and functions from
30:44our local our local repo here as well as
30:47some specific things from web3js as well
30:50as the salana SPL token library and
30:53these metaplex Foundation MPL uh met Lex
30:57library is what that stands for for the
30:59token metadata so we're doing those
31:01Imports and then again we're going to
31:03log out our payer address and our test
31:04wallet and we're going to create a we're
31:07going to randomly generate a Brand New
31:09Key pair for use with this uh use with
31:11our SPL token and then we're going to
31:13define a little bit of configuration
31:15information of our our metadata that we
31:17want to have for our actual token itself
31:21so some of this information will
31:22probably make sense you have a name and
31:23a symbol in this case we're going to
31:25call this 7even C's gold for this uh for
31:27this Workshop we're going to have a
31:28symbol of gold in all caps and a URI
31:31which just points to whatever address
31:33you want and it's just a Json file which
31:36has additional metadata and information
31:38in it for your particular token in this
31:40case we're not actually pointing to a
31:42real URL because doesn't really matter
31:43for the demonstration but if you were
31:45trying to create an actual token that
31:47you want it to be live on mainnet or
31:49something then you would need you know
31:51an actual Json file there but then
31:53there's this other value called decimals
31:55now every single token
31:57has some number of decimals that can be
31:59zero decimal so you can have only whole
32:01numbers and then you can have a bunch of
32:03decimals if you wanted so for our
32:05particular case here we're just setting
32:07two decimals just like you're probably
32:09used to with a normal fiat currency like
32:11Euro or US dollar so on so forth we're
32:14just going to have two decimal places
32:16and there's a certain caveat here that
32:17we'll talk about in a moment for decimal
32:20places and then we're going to actually
32:22start building our instructions similar
32:24to when we created our account on chain
32:25before for the simple instruction or the
32:28simple transaction is we're going to use
32:30our system program. create account and
32:32we're going to create an account this
32:34time we are going to allocate a mint
32:36size worth of space now this is a
32:38constant variable that's pulled in from
32:41the salana SPL token package and it's
32:44basically just a helper value which will
32:46let us uh it'll give us a value of how
32:49much space is required just for this
32:51particular account this is a common
32:53practice that you'll see when you start
32:54interacting with various JavaScript
32:57typescript packages they'll have like
32:59helper functions and helper value so you
33:01don't have to hardcode a bunch of this
33:02it'll be built within their uh within
33:04their package library but so we're going
33:06to allocate that much space however much
33:08space that is and we're going to get the
33:10total uh balance required the minimum
33:13balance for rent exemption of that same
33:15amount of space and this time our token
33:18account our mint account is actually
33:20going to be owned by the token program
33:22and again this value just like the mint
33:25size this is a value that's being
33:27provided from the salana SPL token
33:30package and you can see it has this
33:32token keg is what it starts with so the
33:35token program will have the authority
33:37have the ownership over our mint account
33:40which will allow the token program to
33:42actually mint additional tokens if we
33:44tell it to the next thing we're doing is
33:46we're actually going to initialize that
33:48mint account as a mint so we're
33:50basically going to tell the the token
33:52program that this account is a mint
33:54we've allocated space we're going to
33:56tell it that it is a mint so it can
33:57actually know how to interact with it
33:59correctly and we're just passing in the
34:01required values for that are the value
34:03of it or the the address of it the total
34:05number of decimals and the payer of the
34:08transaction as well as the owner of the
34:11authority the mint Authority and the
34:12freeze Authority for It Whatever address
34:15you provide as the mint Authority is the
34:17only address that will be able to Mint
34:19additional tokens and then freeze
34:21Authority is very similar is you can
34:23it's a similar concept where you can
34:24actually freeze a token so you can
34:26prevent a additional tokens from being
34:28minted if uh if the freeze unless the
34:31freeze Authority allows it you can also
34:33disable additional minting by setting
34:35the freeze authority to a like a null
34:37value so you basically lock it so no one
34:40can ever uh mint additional tokens to
34:42your particular mint next we're going to
34:45uh get the address that we're going to
34:47use for our metadata account to actually
34:49store our tokens metadata on chain now
34:52this is using a concept called a PDA or
34:55program derived address and basically
34:57this is a special type of account
35:00special type of address on the salana
35:02blockchain that makes it so a program
35:05can actually sign transactions for
35:07whatever particular use case you're
35:09you're using so it's it basically comes
35:12down to the cryptographic curve that
35:15salana uses for uh its key Pairs and the
35:19big thing to note here is that we are
35:22this particular metadata account that we
35:24are deriving or like Computing the value
35:27of it's owned by the token metadata
35:29program which starts with meta QB
35:33xx and then we are using a hardcoded
35:36string at the beginnings we're taking a
35:38list of values and we're saying hey this
35:41is the metadata and then the metadata
35:44program as a value and then the mint key
35:47pair that we actually generated earlier
35:50and we're taking all these together as
35:51sort of a key value in a way and we're
35:54using that as a seed to derive our PDA
35:58from our metadata program and we're just
36:01going to log that address out to the to
36:04the console for uh Simplicity or for for
36:06demonstration and then we're going to
36:08actually create our instruction that
36:10will create the metadata account on
36:11chain and of note here we're creating a
36:14metadata V3 instruction so we're just
36:17passing in all the required values and
36:19addresses that we need to actually
36:21create this account we have the metadata
36:23account that we just deriv that PDA
36:25value the mint of our key payer the mint
36:28Authority payer update Authority which
36:30in this case we're just setting the
36:32payer address at The Authority for
36:34everything just for
36:35Simplicity and then we're going to
36:37actually provide the data that we're
36:39going to store in our metadata in this
36:41case we're storing our name our symbol
36:44and some seller fee basis points which
36:46is like a royalty um we're setting all
36:49that to zero just to set null values for
36:51everything for Simplicity and then now
36:53that we've built all three of these
36:54instructions we can bundle those
36:56instructions into a single transaction
36:58just using this helper function uh built
37:01that's within this repo and we're going
37:03to it's basically doing the exact same
37:05thing that we discussed earlier is that
37:07it's getting that recent block hash
37:09putting it inside a version transaction
37:11and it's allowing us to sign with all
37:13the applicable addresses that we need in
37:15this case we need to sign with our payer
37:17because the payer is paying for the fees
37:19in our case and then the mint key payer
37:21because that's that randomly generated
37:23key payer that because we're allocating
37:25that account on on chain it also needs
37:27to sign the transaction so we take those
37:29three instructions we put them in a
37:31single transaction we sign them and then
37:33we send them to the blockchain and then
37:35we're going to Mint them and then we're
37:36going to log out the the information
37:38into our console so let's go ahead and
37:41run that script
37:43now so now that the transaction has
37:45successfully completed and that script
37:46has completed you can see these various
37:49addresses that we logged out we have the
37:50Nick address of our payer we have our
37:52test wallet that's the same test wallet
37:54we used before we we have a new randomly
37:58generated mint address we have the
38:00metadata PDA that we derived and then we
38:03have our transaction that was
38:04successfully sent to the blockchain so
38:07we can go ahead and open this on the
38:08salon
38:10Explorer you can see the standard
38:12information that we've gone through
38:14before but now you can see that we have
38:15additional accounts that are also
38:17included within this transaction uh we
38:20have our our payer we have this
38:22additional signer this in this case this
38:24is our mint we have this uh additional
38:27account here we have System Program
38:29token program and token metadata and
38:31this account is our our metadata account
38:34and then you can look through the
38:35various instructions and kind of look at
38:36the data that's been passed along you
38:39can see with our token metadata
38:40instruction that it has all the accounts
38:43passed in and then we also have
38:44instruction data which you can see the
38:47raw bytes that were actually well
38:48they're hex heximal encoded byes but you
38:51can see the byes that were actually
38:52passed within this instruction so those
38:55are all just going to be logged out into
38:56the console or into the Explorer because
38:59all that data is on chain and then you
39:01can see the program instruction logs as
39:04they executed so now if we go back to
39:07our slide here where we've done the
39:09first three steps of our instructions
39:11that we're we're talking about here but
39:13we haven't actually minted tokens to our
39:16Associated token account or even created
39:18our Associated token account yet so
39:20that's the next thing we go through and
39:21you can like I said before you can do
39:23all of these things in a single
39:25transaction if you want to but more
39:27commonly you're going to be minting uh
39:29if you're minting SPL tokens you're
39:31going to be minting them as multiple
39:32transactions or they're going to be uh
39:35they're going to be manipulated in
39:36multiple transactions so I have it set
39:38up in this particular repo for
39:41demonstration of doing it as two
39:43different transactions and this will
39:45actually make it so we can mint multiple
39:47times just by running our our our mint
39:49script so we'll go ahead and open script
39:52number four mint tokens and we're doing
39:54very similar things we're here we're uh
39:56we're we're loading in those Imports
39:58again we're logging out our payer
39:59address in this case I'm actually
40:01loading in some additional Keys just
40:04Json uh files loaded from a local Json
40:06file I can actually open it here and
40:09that's in this case we're just loading
40:11this token mint just to have that value
40:13because you do need the token mint
40:15address every time you're going to Mint
40:17new tokens to a mint so we're just
40:19getting that and typing it to a public
40:21key correctly but now that we have our
40:24token mint address and again you can do
40:26this all in the same script all in the
40:27same uh instructions but we need to get
40:31or create an Associated token account
40:34like we mentioned before in the slides
40:35the associated token account is actually
40:37the account that's going to have
40:38ownership over the tokens that you
40:41minted that then that associate token
40:44account the ATA is then owned by the
40:47user so the user owns the ATA and the
40:49ATA references back to your tokens so
40:52we're going to get or create our
40:54associate token account and this is just
40:56a helper function that's actually
40:58included within the SPL token SDK and
41:02basically it's going to use a PDA like
41:05we talked about earlier it's going to
41:07derive a PDA address and then it's going
41:09to check if that account has already
41:11been allocated on chain and if it hasn't
41:13it's going to create that account so it
41:15just kind of makes it a little bit more
41:16convenient for us so we don't have to
41:17write that same boilerplate over and
41:19over and over so that's all we're doing
41:21here is we're going to get or create our
41:23associate token account from that is uh
41:26that's we can hover over here that's
41:28owned by the payer or the we're going to
41:31set the payer for the transaction and
41:33the mint of our uh ATA that we're trying
41:36to get and then the actual owner of that
41:40transaction or of that associate token
41:42account so in this case this is the
41:43owner of your tokens you can think of it
41:46like that and then that can be but
41:49doesn't have to be uh a different value
41:51than the payer in this case the payer
41:53just happens to be both but if if you as
41:56a
41:56as a developer you want to create tokens
41:58and airdrop them to people you can pay
42:01for those transactions you can pay to
42:03allocate that space on chain or you can
42:05have the users pay for it depending on
42:06your use case so that's all we're doing
42:08here we're getting this public key value
42:10of our token account and then we're
42:12going to log out that value just for
42:14demonstration and then we can actually
42:16go through the process to Mint tokens
42:18from our mint into our associate token
42:21account and this is where the decimals
42:23are really going to come in and you can
42:24see here in this this uh this script
42:26there's some comments here that kind of
42:28explain what the decimals are used for
42:30but basically when you are minting
42:32tokens under the SPL token program the
42:36decimals do matter quite a bit um so if
42:39you have if you remember back we created
42:41our token mint with decimals of two so
42:44we have two decimal places and if we are
42:45going to request to Mint some amount of
42:48tokens say 1,000 tokens well this also
42:51needs to take in account we want to mint
42:53enough tokens with two decimal places so
42:56if you are have decimal places of two
42:58and you're minting 1,000 you're going to
43:00Mint
43:0110.00 tokens or 10 tokens same thing is
43:04also true if you're minting 10,000 with
43:06decimals of two you're going to Mint 100
43:08tokens so just just uh something to note
43:11there something to keep in mind and now
43:13we can actually go through using this
43:15helper function that's again provided by
43:17the SPL token program SDK and we can
43:20just mint tokens to our associate token
43:23account so we're passing in all the
43:25applicable variables we need whoever's
43:27paying for the transaction the mint of
43:29the tokens we're going to uh actually
43:31mint the ATA that we're going to send
43:34the owner of the
43:36transaction and the number of tokens
43:39that we're actually going to
43:41Mint and then we're just going to log
43:43out the signature to uh an Explorer URL
43:45to the console so let's go ahead and run
43:48this script
43:51now so we'll mint some tokens to our
43:54associate token account and you can see
43:56here in real time it did take a little
43:58bit of time to actually get our
44:00associate token account because we
44:02actually just created that on chain so
44:05if we were to run this script again it
44:06would go a little bit faster because you
44:08just need to derive it which is the
44:10derivation is actually offchain because
44:12it's all the same cryptography under the
44:14hood um but we can go ahead and open our
44:16Explorer URL
44:19here and we can scroll down and see we
44:21now have token balances where we just
44:24minted 10 tokens
44:26to this token and if you look up here
44:29our token's mint is this W9 hn and you
44:32can see this is the token that we
44:34created and then minted tokens to it you
44:37can see here we have our current supply
44:39of 10 because we've only minted 10
44:41tokens so far we have decimals of two
44:43the mint Authority and freeze Authority
44:45just like we talked about
44:46earlier so now we can go ahead and run
44:49the script again mint an additional 10
44:51tokens because we haven't changed any
44:53values and you can see that getting this
44:55PDA address was a lot faster because we
44:57didn't need to actually create it so now
45:00we can open this Explorer URL it's going
45:02to look very similar to what we saw
45:05before same thing same addresses because
45:08we are minting the same address we've
45:10now mint an additional 10 tokens but now
45:12we have a post balance of
45:1510 so we can open this back up we and
45:18close this other one and you can see now
45:20our current Supply is 20 tokens still a
45:23decimals of two because we haven't
45:24changed our decimals and we have an
45:26additional transaction that has occurred
45:28so super cool there so the next thing I
45:31want to talk about is that you can
45:32actually update your token metadata as
45:34long as your token's not frozen your
45:36metadata is not frozen you can actually
45:38update the metadata so you can see here
45:40this particular token we created is
45:42named 7even C's gold and if you scroll
45:45down on the Explorer you can go to the
45:46metadata Tab and you can see the
45:48different bits of metadata that's
45:50actually stored with this token that we
45:52created so we have 7even se's gold a
45:55gold is the symbol and this Json URI but
45:59because our token's not frozen we can
46:01actually go through and we can update
46:02all this metadata if we really want to
46:04so we'll go ahead and quickly
46:05demonstrate that uh so if you open up
46:07script number five you can see standards
46:10the same stuff as before we loading in
46:12our token mint and our payer address and
46:15then we're actually creating some new
46:16token metadata information so we're
46:18going to change the name the symbol and
46:21I think our URL is going to stay the
46:22same yeah oh this URI is also going to
46:25change you can see it's called new. Json
46:27instead of info. Json so we're going to
46:29change all of those values and we'll be
46:31able to see that reflected on chain
46:33immediately which is really cool so
46:35we're going to go through the process
46:36we're going to derive our PDA for our
46:39metadata account just like we did before
46:41we're taking a static value a static
46:44string of metadata our metadata program
46:46address token mint and it's owned by the
46:49metadata program we're going to log that
46:50metadata account address out and we are
46:53going to create an update instruction
46:56this is a update metadata V2
46:59instruction and we're passing in all
47:01that information to this instruction uh
47:04Builder helper function and then we're
47:07going to take that instruction we're
47:08going to build a transaction we're going
47:09to sign it with the payer in this case
47:11because the payer is going to sign is
47:13going to pay for the transaction fees
47:14but also the payer is the authority of
47:17our particular token if your Authority
47:20was a different address that a different
47:23different account that account would
47:24also need to sign the transaction but
47:26because they are the same for this
47:27demonstration I only have a Single Payer
47:29on this but we're going to build that
47:31transaction we're going to send it to
47:33the blockchain and we're going to you
47:35know do some some simple error handling
47:37so let's go ahead and run script number
47:41five so you can see that once the script
47:44executes uh successfully we can see a
47:46transaction Explorer URL so we can open
47:49it up on
47:50Explorer and you can see you know
47:52standard stuff transaction executed
47:54successfully see the to tokens uh the uh
47:56the accounts that we actually interacted
47:58with our instructions that we executed
48:01and you can see all these bytes that we
48:03have submitted within our instruction
48:05and we can open our token mint because
48:08we updated our token mint uh metadata we
48:11can open this again on the Explorer and
48:13we can see now it's uh it's been updated
48:17so we can go back to this same address
48:19we had here you can see it in the URL
48:21bar this W9 hn W9 hn
48:26and we can go to the metadata Tab and
48:29you can see that all of our metadata has
48:31now been updated well these specific
48:33fields that we actually did update but
48:35we updated the metadata directly on
48:36chain really cool stuff so now we can go
48:40back to our slideshow here and you can
48:42see that we've now successfully
48:43completed all of these four uh four
48:45bullet points here and uh we did it as
48:48two different transactions well really
48:50three different transactions for the
48:51demonstration but you can all do it as
48:53one single transaction to create a a
48:55complete new SPL token uh allocate the
48:58space on chain for it initialize that
49:01mint create the associate token account
49:03and uh mint tokens to that
49:06ATA so some key takeaways just to
49:08summarize all the bit about SPL tokens
49:11is that you do not need to deploy a new
49:14program in order to create new tokens on
49:16the salana blockchain which is really
49:18convenient uh you can create new tokens
49:20using only one single transaction one
49:22single RPC call and all the related
49:25accounts are used to describe those
49:27tokens like you have your mint you have
49:30your Associated token account you have
49:31the metadata account you have all these
49:33different accounts that interact in this
49:34composable manner and that's really one
49:36of the strong uh powerful points about
49:39salana so now just to summarize again
49:41the overview of minting new SPL tokens
49:43on salana is that you create a new
49:46account and you initialize that account
49:47as a token mint then you can create the
49:50metadata account for that mint which is
49:53going to store that that random you know
49:55or that specific metadata like your name
49:57your symbol your Json URI that sort of
49:59thing and a wallet will then own an
50:02Associated token
50:04account which then will have some
50:07balance of your particular token which
50:09has a direct relationship between the
50:11wallet owner the associated token
50:13account owner and then your
50:16mint and we've already gone through the
50:18process of demonstrating the code on how
50:20to actually create mint and mint
50:22tokens so now that we've talked about
50:24SPL tokens let's talk about nfts and
50:27realistically nfts are SPL tokens
50:30actually so on the salana blockchain
50:32every single
50:33nft is actually an SPL token they have
50:37they have some specific unique
50:39properties that enable them to be nfts
50:42like non-fungible tokens that's what nft
50:44stands for and some of those properties
50:46are that the specific decimal places for
50:49each mint is zero decimal places because
50:52you just want one you want nonf fungible
50:56and they have exactly a supply of one
50:59and they can actually have highly
51:01customizable metadata with them you can
51:04have multiple images you can have all
51:05sorts of attributes and things like that
51:08and you might be used to some of this
51:09type of information displayed on on your
51:11favorite marketplaces of
51:13nfts so there's two pieces of
51:16information you also have with nfts is
51:19that you have what's called a master
51:20Edition and a collection and in fact
51:23each of these are basically just
51:25accounts that are also stored on chain
51:27but a collection is actually just
51:30another nft so it's an nft grouping that
51:35actually just has a relationship to all
51:37the nfts within a collection and the
51:40master Edition is just used to the
51:42master Edition account is just used to
51:44store uh some specific metadata
51:46information we're not going to go super
51:48in- depth into the master Edition
51:50concept and everything that goes into
51:51that but we'll talk a a little bit about
51:53collections once we go through the
51:55process of actually creating an nft
51:56collection and creating nfts which we'll
51:59do right now so let's go ahead and
52:01actually mint some nfts on the salon of
52:02blockchain so we're going to go ahead
52:05and open script number
52:06six which is called create
52:09nfts I'll clean up my vs code here so
52:13we'll go ahead and open up script number
52:14six create nfts and we're doing these
52:17very similar things that you that we've
52:19demonstrated uh all along you you're
52:21probably detecting this pattern of you
52:23know you're going to do the exact same
52:24thing for your scripts and a lot of your
52:26code you're going to have all your
52:27Imports you're going to get your keys
52:29that you need whatever way you're going
52:31to get those keys you know it's going to
52:33change depending on the application that
52:34you're building um but for nfts we're
52:37going to create some metadata uh we're
52:39going to Mint this image here and we
52:42just have a uh nft storage link here
52:45which basically just the a decentralized
52:47uh storage provider using the ipfs uh
52:50Network and we're going to give it a
52:53name a symbol and description and uh we
52:56can we can open this image too um just
52:58to show what it looks like it's this
53:00cool uh gradient pirate ship looking
53:03image so we're going to actually mint
53:05this particular nft on the salana
53:07blockchain now in this case instead of
53:09using instead of uh manually building
53:12all the instructions that you need in
53:14order to uh handle all of the the
53:17actions the instructions and the
53:18transaction you need to Mint nfts we're
53:21actually going to use the metaplex uh
53:23the metaplex SDK
53:25and the metaplex SDK is it's an open
53:28source SDK provided by the metaplex
53:30foundation and it uh it gives a lot of
53:33helper functions that you can use to
53:35actually create nfts and and work with
53:38nfts on the salana blockchain so we are
53:41going to create a new metaplex instance
53:44provided our connection we're going to
53:46give it our key pair which is our payer
53:48since this is going to be the payer uh
53:51address that we're going to use to sign
53:52all these transactions and then because
53:54we're also going to use it to upload
53:57some our metadata to ipfs using the
54:00bundler network in
54:01ipfs uh we're actually providing some
54:04information here and basically because
54:06we're on devet we have to provide this
54:08additional information if you're on
54:10mainnet and you're trying to do this you
54:12don't need any of this uh these
54:14configuration values um but the first
54:17thing we're going to do is we're going
54:18to use the metaplex SDK we're going to
54:20upload this metadata which is just a
54:23JavaScript object and it's going to
54:25upload this object as Json to the ipfs
54:29network decentralized file storage and
54:31we're just going to log out that URI to
54:33the console so that way we can see what
54:35it looks like but then we're going to
54:36use that URI and our name and our symbol
54:39and we're going to Mint our first nft
54:41and again we're using the metaplex SDK
54:43so it makes it super super easy to
54:45actually mint nfts we're going to use
54:48the metaplex nts. create pretty
54:50self-explanatory what it's doing there
54:52and we're providing in all of our
54:53assorted metadata that we want want uh
54:55we're going to give it our image our our
54:57metadata URL which links back to our
55:00image we're going to give it the name
55:01and our symbol and we're setting seller
55:03fee basis points and these are basically
55:06the royalties that you would see on
55:09various marketplaces now to note that
55:11these are royalties requested you can
55:15kind of think of it like that um unless
55:17unless the particular nft collection is
55:19set up in a certain way is basically
55:21saying you as the Creator are requesting
55:24in this case 5% 500 basis points or bips
55:27for short uh you're requesting a 5%
55:29royalty on all sales and they'll be paid
55:32back to your your royalty address that
55:34you set up uh in our particular nft
55:36we're going to set it as mutable so that
55:38way we can actually mutate and and
55:40update the metadata for our nft if we
55:41want which we're not going to cover in
55:43this demonstration but uh you'll have
55:45that functionality and then we're just
55:47going to log out the nft object that
55:49gets returned from the metaplex SDK and
55:52we're going to send or we're going to
55:54log out our signature so we can actually
55:55view that transaction on the Explorer so
55:58let's go ahead and run this
56:02script so we'll go ahead and scroll back
56:04to the top here and we'll uh we'll talk
56:06about what happened is that we logged
56:08out our token mint because we're just
56:10using our same uh mint that we had
56:12earlier uh we're you know the same
56:15Explorer URL there and we you can see
56:18here we have this URL on R weave because
56:21we're actually using I think I misspoke
56:22earlier we're using R weave to actually
56:24upload us using bundler that bundler is
56:26using R weave the r weave Network which
56:28is again a different decentralized file
56:30storage we can actually open this R
56:33weave address and you can see that we
56:35have our exact uh object that we had
56:38uploaded but then we're actually we have
56:40this large data object here and this is
56:42the nft data object that gets returned
56:45from the metaplex SDK and you can see
56:47all the various addresses and data that
56:49we actually set when we created our nft
56:52using
56:53metaplex we have our update Authority in
56:56this case it's just the payer that I had
56:58Set uh I didn't specify an update
57:00Authority but because it was the payer
57:02that's what it defaults to you can see
57:04all of our Json that we had uploaded
57:07using that um the using the bundler
57:10network and uploading to R weave and
57:12then you can see the other assorted um
57:15metadata that we have with our
57:17nft we had set a seller fee basis points
57:21and since we had not set a specific
57:23Creator it Auto automatically detects
57:25that as the payer and then sets the
57:27payer as that
57:29Creator and then you can see some some
57:31other Associated information about uh
57:34our particular nft you can see the mint
57:37and our mint Authority freeze Authority
57:38decimals of zero just like we talked
57:40about earlier and just the sort of
57:43information about our token the nft
57:45Edition which we're not going to talk
57:47much about here but if you're interested
57:48more about nfts you can go read through
57:51the metaplex docs at docs. metaplex dcom
57:54and and uh and read all about nft
57:56additions and things but we can go ahead
57:58and open our transaction on the
58:01blockchain Explorer and we'll see what
58:03it looks like so once it loads up you
58:05can see we just minted this one and you
58:07can see this is a far more complex
58:10transaction that we than we had
58:12previously built up until this point you
58:14can see a list of 12 different accounts
58:17that were included within this
58:18transaction you have a couple of
58:20different accounts that are all writable
58:22some that have no right or signer fee
58:24pay or anything like that and that's
58:26just cuz those are read
58:28accounts and you have our program that's
58:30actually executing this transaction in
58:32this case token metadata
58:34program and you can see a token balance
58:37we have this token of
58:39hzd 7 and we changed it by one token
58:43because that is the actual nft that we
58:45just minted you can see all the metadata
58:47that we set within our nft we have our
58:49name our symbol and our image and you
58:53can also look at the Creator you can see
58:54that was the creator address that the
58:56metaplex SDK had set for us and then if
58:59you're interested you can kind of look
59:01through the various instructions that
59:02were actually executed so if you wanted
59:04to kind of deconstruct this and uh maybe
59:06handle it yourself manually you can
59:08absolutely do that or you can look
59:09through the metaplex SDK and actually
59:12look at the source code for the SDK
59:13since it is open source and see how
59:15they're deing it that way so that's the
59:18process of actually creating nfts on the
59:20salana blockchain it's pretty
59:21straightforward super cool so just to
59:24summarize some key takeaways is that
59:26nfts are SPL tokens under the hood is
59:29that they but they have those unique
59:31properties they have zero decimal places
59:33and they have a supply of exactly one
59:36and they all have assorted metadata
59:38associated with them and that metadata
59:40is highly customizable there's a lot of
59:42information that you can put inside of
59:43an nf's metadata and again if you're
59:46interested you can read up on those on
59:48the metaplex docs so that's it for the
59:50explicit code walkthroughs but I'll
59:52quickly talk about the account structure
59:53and some of the data structures that we
59:55had just discussed and just discovered
59:58um just more explicitly so if you think
01:00:01back to our SPL tokens we had our mint
01:00:03account that we created and you can see
01:00:05we have some number of decimals you can
01:00:07see the the math calculation there you
01:00:09have the uh is initialized the supply
01:00:12mint Authority freeze Authority and
01:00:13those are all the values that we had set
01:00:15on our mint when we actually created
01:00:17it and then with nfts you have decimals
01:00:20of zero and then because they're
01:00:23effectively the same thing thing under
01:00:25the hood it's just which uh particular
01:00:27addresses and specific metadata you are
01:00:30associating with those particular SPL
01:00:33tokens and then when you think back to
01:00:36your Associated token accounts is that
01:00:38we are deriving an Associated token
01:00:40account address that's that's what that
01:00:42is it's an uh the ATA is a PDA and we're
01:00:46using that program derived address with
01:00:48the seeds of our users's wallet the
01:00:50token program and the mint address and
01:00:52that's all owned by the associated token
01:00:54program and basically those are just
01:00:57storing a bit of data which just
01:01:00effectively has a balance that's all it
01:01:03is and then once if you think back to
01:01:06our metadata account that we had created
01:01:07for our nft or for our SPL token in
01:01:11general very similar thing we der we
01:01:14derived a PDA using the static uh value
01:01:17of metadata the metadata program and the
01:01:19mint address and that's owned by the
01:01:22metadata program and then Within that
01:01:25data structure you're actually storing
01:01:27um some of that specific uh data on
01:01:30chain specifically our title symbol and
01:01:33a URI value which that URI is is stored
01:01:37off chain so you have to then fetch that
01:01:38data and that that gets handled and then
01:01:40you have the list of creators as well so
01:01:43just to summarize those key takeaways is
01:01:45that mint accounts house data for a mint
01:01:49for a token mint and then the associated
01:01:51token account stores a user's balance
01:01:53and metadata can store the the assorted
01:01:55metadata information for a particular
01:01:58mint so lastly to close out day one of
01:02:01this workshop and of this boot camp um
01:02:03the challenge is to actually create your
01:02:05own nft collection with a fleet of
01:02:07pirate ships for the 7even se's game
01:02:09that you're going to learn how to build
01:02:10in this Workshop uh mint it with I don't
01:02:12know like 32 different pirate ships use
01:02:15different images try to play around with
01:02:17ipfs and rwe storage and if you look
01:02:20through the code in this repo there are
01:02:22some example links and and doent
01:02:24references for uh more information on
01:02:27those and then create an additional
01:02:29three SPL tokens for gold rum and
01:02:32cannons thanks for watching and I hope
01:02:34you learned a lot in this
01:02:37video
🎥 Related Videos![What vaccinating vampire bats can teach us about pandemics | Daniel Streicker](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FlSPxeA6Z_m4%2Fhqdefault.jpg&w=3840&q=75)
![a16z Podcast | Things Come Together -- Truths about Tech in Africa](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fjbl5I7kYWHM%2Fhqdefault.jpg&w=3840&q=75)
![2024 TSCRS Applications of anterior segments diagnostic instruments in cataract surgery](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FWnUDk5vKuqE%2Fhqdefault.jpg&w=3840&q=75)
![a16z Podcast | The Infrastructure of Total Health](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FoLGRslHa5FE%2Fhqdefault.jpg&w=3840&q=75)
![The Robot Lawyer Resistance with Joshua Browder of DoNotPay](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FAmVdYPTdw2c%2Fhqdefault.jpg&w=3840&q=75)
![NES Controllers Explained](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FnAStgQzPrAQ%2Fhqdefault.jpg&w=3840&q=75)
![What vaccinating vampire bats can teach us about pandemics | Daniel Streicker](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FlSPxeA6Z_m4%2Fhqdefault.jpg&w=3840&q=75)
What vaccinating vampire bats can teach us about pandemics | Daniel Streicker
![a16z Podcast | Things Come Together -- Truths about Tech in Africa](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fjbl5I7kYWHM%2Fhqdefault.jpg&w=3840&q=75)
a16z Podcast | Things Come Together -- Truths about Tech in Africa
![2024 TSCRS Applications of anterior segments diagnostic instruments in cataract surgery](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FWnUDk5vKuqE%2Fhqdefault.jpg&w=3840&q=75)
2024 TSCRS Applications of anterior segments diagnostic instruments in cataract surgery
![a16z Podcast | The Infrastructure of Total Health](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FoLGRslHa5FE%2Fhqdefault.jpg&w=3840&q=75)
a16z Podcast | The Infrastructure of Total Health
![The Robot Lawyer Resistance with Joshua Browder of DoNotPay](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FAmVdYPTdw2c%2Fhqdefault.jpg&w=3840&q=75)
The Robot Lawyer Resistance with Joshua Browder of DoNotPay
![NES Controllers Explained](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FnAStgQzPrAQ%2Fhqdefault.jpg&w=3840&q=75)
NES Controllers Explained
🔥 Recently Summarized Examples![4 Steps to Master Any Complex Skill (quickly)](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FpHN7BXpdAPQ%2Fhqdefault.jpg&w=3840&q=75)
![40 Years of Fitness Experience in Less Than 11 Minutes.](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2ZsHsX4hvlk%2Fhqdefault.jpg&w=3840&q=75)
![Gun Controlling Media Makes FATAL Mistake... They Have Tied Their Fate To Biden's & Gun Rights Win](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8L34kAwjriw%2Fhqdefault.jpg&w=3840&q=75)
![GET READY! Palantir Is Officially The Next Nvidia.](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FscpVS5--ikw%2Fhqdefault.jpg&w=3840&q=75)
![Abundant Thinking: The Hidden Key to Get Everything You Want (Audiobook)](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2Far9dcxJ11H4%2Fhqdefault.jpg&w=3840&q=75)
![The Coming Demonic Invasion (Revelation 9:12–21)](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDYzkCtbwHqU%2Fhqdefault.jpg&w=3840&q=75)
![4 Steps to Master Any Complex Skill (quickly)](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FpHN7BXpdAPQ%2Fhqdefault.jpg&w=3840&q=75)
4 Steps to Master Any Complex Skill (quickly)
![40 Years of Fitness Experience in Less Than 11 Minutes.](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2ZsHsX4hvlk%2Fhqdefault.jpg&w=3840&q=75)
40 Years of Fitness Experience in Less Than 11 Minutes.
![Gun Controlling Media Makes FATAL Mistake... They Have Tied Their Fate To Biden's & Gun Rights Win](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8L34kAwjriw%2Fhqdefault.jpg&w=3840&q=75)
Gun Controlling Media Makes FATAL Mistake... They Have Tied Their Fate To Biden's & Gun Rights Win
![GET READY! Palantir Is Officially The Next Nvidia.](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FscpVS5--ikw%2Fhqdefault.jpg&w=3840&q=75)
GET READY! Palantir Is Officially The Next Nvidia.
![Abundant Thinking: The Hidden Key to Get Everything You Want (Audiobook)](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2Far9dcxJ11H4%2Fhqdefault.jpg&w=3840&q=75)
Abundant Thinking: The Hidden Key to Get Everything You Want (Audiobook)
![The Coming Demonic Invasion (Revelation 9:12–21)](/_next/image?url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDYzkCtbwHqU%2Fhqdefault.jpg&w=3840&q=75)