Onboarding challenge from TON Foundation w/ Mark Okhman

Mark Okhman
23 Dec 202245:41

Summary

TLDR在这段视频中,Mark 带领观众通过一个互动教程,体验在TON区块链上挖掘NFT的过程。他首先介绍了TON区块链的基本概念,包括主网和测试网的区别,并解释了测试网是开发者学习和实验的理想环境。接着,Mark详细演示了如何使用TON Keeper钱包在测试网上进行交互,包括安装钱包、启用测试模式、以及如何通过编写和发送智能合约来“挖掘”一个NFT。他还展示了如何构建和签署交易,以及如何通过扫描QR码来完成交易。最后,Mark鼓励观众通过实践来克服对编程的恐惧,并提供了额外的学习资源和社区支持,以帮助他们更深入地了解TON区块链和智能合约的开发。

Takeaways

  • 🚀 **启动挑战**:Mark介绍了一个关于构建下一代十亿用户的挑战,鼓励观众开始在TON网络上编程。
  • 👕 **口号与目标**:他穿着印有“为下一个十亿用户构建”的T恤,表明了视频和项目的目标。
  • 📈 **TON的增长**:提到了TON价格的增长,并强调了为了跟上这种增长,需要快速发展和编程。
  • 🛠️ **智能合约入门**:为不熟悉智能合约的观众提供了一个入门挑战,说明即使没有编写自己的智能合约,也有很多可以构建的东西。
  • 🎓 **新手友好**:视频旨在帮助新手克服对编程智能合约的恐惧,并通过实际操作与智能合约交互。
  • 📚 **教程与资源**:Mark提供了一个链接到他的Telegram频道,以便获取更多教程和文章。
  • ⛏️ **NFT挖矿挑战**:介绍了一个关于在TON网络上“挖矿”NFT火箭的挑战,尽管TON实际上没有挖矿。
  • 🤖 **测试网交互**:说明了将与TON的测试网进行交互,这是一个用于开发和测试的网络环境。
  • 💻 **开发者环境设置**:介绍了如何设置本地开发环境,包括安装Git、Node.js和Visual Studio Code。
  • 🔗 **API连接**:解释了如何连接到TON Center API,这是一个与区块链通信并提供数据的服务器。
  • 🔑 **钱包和交易**:展示了如何使用TON Keeper钱包,并在测试网上启用测试模式,以及如何发送交易。
  • 🔗 **构建消息和交易**:详细介绍了如何构建一个消息,将其转换为一个可以由钱包签名并发送到智能合约的交易。
  • 🔍 **数据结构**:讨论了TON中的数据结构,特别是Cell的概念,以及如何使用TypeScript与之交互。
  • 📝 **代码和交易**:通过实际代码示例,展示了如何编写与智能合约交互的代码,以及如何发送交易以获取NFT。
  • 🔄 **测试网和主网**:阐明了测试网和主网的区别,以及为什么测试网是开发者学习和实验的理想场所。
  • 🎉 **成功获取NFT**:Mark成功地通过一系列步骤在测试网上获取了一个NFT,展示了整个过程。

Q & A

  • 马克在视频中提到了哪个平台的智能合约?

    -马克在视频中提到了TON区块链的智能合约。

  • 在TON区块链上进行挖矿需要什么条件?

    -在TON区块链上进行挖矿需要一个钱包、一个代码库、开发者环境,并且需要通过提供工作证明(Proof of Work)给智能合约来获得TON币和NFT作为奖励。

  • 什么是Testnet,它与Mainnet有何不同?

    -Testnet是区块链的测试网络,它允许开发者在不涉及真实货币的情况下测试交易和智能合约。与Mainnet不同,Mainnet是实际的区块链网络,其上的交易和币值是真实的。

  • 马克在视频中提到了哪些工具或应用?

    -马克提到了Ton Keeper、Openmask、Node.js、VS Code等工具或应用。

  • 在视频中,马克是如何解释智能合约的getter函数的?

    -智能合约的getter函数是一种特殊的函数,它能够从智能合约的存储中返回特定的数据。在视频中,马克通过调用getter函数来获取挖矿数据,如工作证明的复杂度和最后成功的种子值。

  • 如何理解视频中提到的'Proof of Work'?

    -在视频中,'Proof of Work'指的是用户需要进行一些计算,找到一个小于特定复杂度值的哈希值。这个计算过程被视为工作证明,是用户获得NFT奖励的前提。

  • 马克在视频中提到了如何获取Testnet上的TON币,这需要哪些步骤?

    -马克提到,为了在Testnet上进行交易,用户需要获取Testnet上的TON币。这通常涉及访问特定的Testnet币保地址,按照提供的步骤获取免费的测试币。

  • 在视频中,马克解释了如何构建一个支付链接,这个链接是用于什么目的?

    -在视频中,马克解释了如何构建一个支付链接,这个链接用于将用户找到的有效哈希值发送到智能合约,并以此来证明工作量,从而获得NFT。

  • 马克在视频中提到了哪些关于智能合约编程的语言?

    -马克提到了TypeScript和Fift(Fancy的简称),这两种语言在智能合约编程中使用。

  • 在视频中,马克是如何描述智能合约和TypeScript之间的关系的?

    -马克用火箭将卫星送入轨道的比喻来描述智能合约和TypeScript之间的关系。TypeScript像是将智能合约这个“卫星”送入区块链网络“轨道”的“火箭”,一旦智能合约在区块链上部署,TypeScript就不再需要了。

  • 马克在视频中提到了哪些关于TON区块链的资源或链接?

    -马克提到了TON的文档网站、他的Telegram频道以及他的YouTube频道,这些都是学习TON区块链和智能合约编程的资源。

Outlines

00:00

🚀 欢迎来到频道并介绍智能合约挑战

Mark欢迎观众来到他的频道,并介绍了他们将要进行的智能合约挑战。他提到了为未来十亿用户构建应用程序的目标,并展示了一个代表TON区块链上周价格的火箭。Mark鼓励初学者开始编程,并介绍了如何在不编写自己的智能合约的情况下与智能合约进行交互。他还提到了一个链接,观众可以通过该链接加入他的Telegram频道以获取更多教程和文章。

05:01

📚 设置开发环境并了解智能合约

Mark指导观众如何设置本地开发环境,包括安装Git、Node.js和VS Code。他展示了如何克隆GitHub仓库并安装所需的软件包。Mark解释了如何连接到TON Center API,这是一个与区块链通信并提供数据的服务器。他还介绍了如何使用智能合约的getter函数来获取特定数据,如工作量证明的复杂性和种子值。

10:01

🔗 连接到智能合约并准备数据

Mark解释了如何连接到智能合约并获取挖掘所需的信息。他展示了如何使用API读取数据,以及如何编写代码来计算哈希值,这是挖掘过程中的关键步骤。他还讨论了如何构建一个消息并将其发送回智能合约,以及如何使用测试网(testnet)进行开发和学习。

15:03

🤖 使用TypeScript和智能合约进行交互

Mark讨论了如何使用TypeScript与智能合约进行交互。他展示了如何创建一个函数来解析和准备挖掘消息,以及如何使用while循环来计算哈希值,直到找到满足条件的哈希。他还提到了如何使用Unix时间戳和数据来构建挖掘消息,并强调了在找到合适的哈希后需要快速发送交易的重要性。

20:05

💰 构建支付链接并发送交易

Mark指导观众如何构建支付链接,这是发送消息到智能合约并接收NFT所必需的。他解释了如何在TON中将货币转换为Nano单位,并如何创建一个包含所需信息的交易体。他还讨论了如何生成一个QR码,以便使用TON Keeper钱包扫描并签署交易。

25:06

🔗 扫描QR码并签署交易

Mark展示了如何扫描QR码并使用TON Keeper钱包签署交易。他强调了非托管钱包的重要性,因为它们允许用户完全控制自己的私钥和交易。他还提到了如何将已签名的交易发送到测试网的后端,并在验证后将其推送到区块链上。

30:18

🚀 成功获取NFT并探索更多

Mark确认了NFT的成功获取,并展示了如何在testnet上查看交易。他提到了如何获取测试网的TON币,这是进行交易所必需的。Mark还提到了他计划录制关于如何在testnet上出售NFT的另一个视频,并鼓励观众阅读智能合约的代码以更好地理解整个过程。

35:20

📝 深入理解智能合约和TON编程

Mark深入探讨了智能合约的概念和TON编程的复杂性。他解释了如何使用TypeScript编写代码,这些代码最终会被转换并发送到TON虚拟机(TVM)。他还讨论了如何构建一个单元(cell),这是一个在TON中用于存储数据的数据结构。Mark鼓励观众耐心学习,并提供了更多资源和社区支持,以帮助他们克服学习过程中的挑战。

40:21

🎉 总结并鼓励观众继续学习

Mark总结了视频内容,并鼓励观众继续学习和探索TON编程。他提供了对未来教程和办公时间的预告,并鼓励观众加入开发者社区,提出问题并寻求帮助。Mark表达了对观众成功的祝愿,并期待在下一个视频中再次见到他们。

Mindmap

Keywords

💡智能合约

智能合约是一种自动执行、控制或文档化法律事件和行动的计算机程序。在视频中,智能合约被用作一种机制,允许用户通过完成特定的工作量证明(Proof of Work, PoW)来获取NFT。例如,视频提到通过与已部署在测试网上的智能合约交互,用户可以进行计算并获得NFT作为奖励。

💡测试网

测试网是区块链的副本,用于在不影响主网的情况下测试和开发。在视频中,提到了使用测试网进行交互,用户可以在没有风险的情况下学习和尝试智能合约的交互,例如通过测试网与智能合约交互来获取NFT。

💡工作量证明(Proof of Work)

工作量证明是一种加密货币网络安全机制,要求用户执行一定量的计算工作以获得网络认可。在视频中,用户需要提供工作量证明给智能合约,通过计算一个小于复杂度的哈希值来“挖掘”NFT。

💡非同质化代币(NFT)

NFT是一种代表独特资产所有权的加密代币,与比特币等同质化代币不同,每个NFT都是独一无二的。视频中的挑战是让用户通过智能合约的交互来挖掘一个NFT火箭。

💡TON区块链

TON区块链是一个高性能的区块链平台,旨在支持去中心化应用和智能合约。视频内容围绕如何在TON区块链上进行智能合约的交互和NFT的获取展开。

💡TON Keeper

TON Keeper是一个非托管钱包,用于与TON区块链交互。在视频中,提到了安装和使用TON Keeper钱包来签署交易,这是获取NFT所必需的步骤。

💡数据结构(Cell)

在TON区块链中,Cell是一种存储数据的数据结构,用于在智能合约中传递数据。视频解释了如何使用TypeScript来构建一个Cell,并将其发送到智能合约中。

💡交易构建器(Transaction Builder)

交易构建器是一个工具或库,用于创建和构建区块链交易。在视频中,交易构建器被用来创建一个包含必要数据的消息,以便发送到智能合约并获取NFT。

💡TypeScript

TypeScript是一种编程语言,是JavaScript的一个超集,添加了类型系统和一些其他特性。在视频中,TypeScript被用来编写与TON区块链智能合约交互的代码。

💡QR码

QR码是一种可以快速读取数据的二维条码。在视频中,提到了生成QR码以便于使用TON Keeper钱包扫描并签署交易,这是获取NFT过程中的一个步骤。

💡TON区块链浏览器

TON区块链浏览器是一种工具,允许用户查看和搜索TON区块链上的交易和地址。视频的最后提到了使用TON区块链浏览器来验证NFT的获取是否成功。

Highlights

马克介绍了如何为下一个十亿用户构建应用程序,以及如何通过编程参与智能合约。

即使对智能合约不熟悉,也有很多无需编写智能合约即可构建的内容。

介绍了如何通过测试网与智能合约交互,以及测试网与主网的区别。

解释了如何在测试网上进行NFT挖掘,尽管在TON中实际上没有挖掘过程。

展示了如何使用TON Keeper钱包,并在测试模式下进行操作。

提供了一个预先构建的代码库,用于开始智能合约的交互。

详细说明了如何通过TON Center API获取挖掘数据。

介绍了如何计算哈希值并找到满足特定条件的哈希以进行NFT挖掘。

展示了如何构建和发送包含必要数据的消息到智能合约以获取NFT。

解释了为什么每个消息在TON中都是一笔交易,并且需要支付一定的费用。

讨论了如何准备和发送交易,包括如何生成QR码以在TON Keeper钱包中签名。

强调了在测试网上进行操作的重要性,以便开发者可以在没有风险的环境中学习和实验。

提供了如何获取测试网TON币的指南,以便用户可以在测试网上进行交易。

展示了如何在测试网上成功挖掘并获取NFT的整个过程。

讨论了智能合约的工作原理,以及如何在TON中构建和部署智能合约。

解释了TON中的单元(Cell)数据结构,以及它是如何在交易中使用的。

强调了学习TON编程的重要性,并鼓励观众通过实践来提高他们的技能。

提供了额外的学习资源和社区支持,以帮助开发者在TON平台上取得成功。

Transcripts

play00:00

foreign

play00:02

what's up guys my name is Mark welcome

play00:05

to my channel if you're wondering what

play00:07

we are doing here it's we are building

play00:10

for the next billion users just like my

play00:13

t-shirt States

play00:14

so

play00:15

um you can see right now behind my back

play00:18

the onboarding challenge and there's a

play00:21

rocket and this is nothing else but

play00:22

representation of tons price last week

play00:25

and because we have to keep up we have

play00:27

to grow as fast as Tom grows we have to

play00:31

start if you didn't start yet start

play00:34

programming on top so today's challenge

play00:37

is going to be for those who were afraid

play00:40

a little bit of smart contracts and

play00:41

everything but there is a plenty of

play00:43

things you could build without touching

play00:45

smart contract and uh I mean not to

play00:48

touching but without building and

play00:50

programming your own smart contract so

play00:52

for those who are new this is going to

play00:54

be perfect to get your first like

play00:57

Hands-On uh interacting with smart

play00:59

contracts

play01:00

but

play01:02

um for those who want to dig deeper

play01:03

there's going to be also a small part at

play01:05

the end maybe if you don't want to go

play01:07

through the whole like step-by-step

play01:09

tutorial you could just jump uh to the

play01:12

part where we are digging a little bit

play01:14

deeper on the on how commands of uh

play01:17

smart contracts work

play01:18

but uh I very much hope that a person

play01:23

who was a little bit afraid of starting

play01:25

programming for Tong now is going to get

play01:27

his answers so you guys gonna see how

play01:29

I'm doing some stuff step by step and I

play01:32

hope this is going to encourage you to

play01:34

start programming so before we start if

play01:37

you don't mind please like And subscribe

play01:39

and also there's a description and then

play01:42

description there's a link to my

play01:43

telegram channel so if you want to get

play01:46

more tutorials if you want to learn more

play01:48

stuff sometimes some articles just

play01:50

follow there you're gonna stay tuned so

play01:52

let's get to the actual business

play01:56

let's

play01:58

um

play01:59

see what we got here so this onboarding

play02:01

challenge is stating that we will mine

play02:04

an nft rocket

play02:07

it's first miners on tone you'll go

play02:09

through proof of work smart contract and

play02:11

final minus secret reward

play02:13

disclaimer there's no mining in tone

play02:15

there was some and if you want you can

play02:19

actually go and read more about this

play02:21

it's like story history of mining on

play02:24

tone so basically long story short

play02:27

um mining on tone was kind of like a

play02:30

replacement for an Ico so uh you had to

play02:35

provide some proof of work to the smart

play02:37

contract Anton and then you will be

play02:39

receiving the tons and the very first

play02:42

mining actually was on testnet and we

play02:46

are going to interact with testnet what

play02:48

is testnet I will just quickly

play02:50

um

play02:51

overview that so testnet like the

play02:54

mainnet this is a

play02:56

antonyms like Main and test so mainnet

play03:00

is a network of nodes that are actually

play03:03

syncing with each other sending each

play03:05

other transactions and they're actually

play03:06

validating each transaction that comes

play03:09

into this net Network and uh so mainnet

play03:13

coins are actually worth of money tall

play03:16

but there's also test net and on testnet

play03:19

there's also test coins and there are

play03:21

test smart contracts so this is a

play03:22

perfect place for developers to play

play03:24

around to fail to learn and we are going

play03:28

to interact with testnet and so as the

play03:31

creator of this uh

play03:33

challenge States we are going to get an

play03:36

nft

play03:37

on testnet on the address that we will

play03:40

use to interact with some specific smart

play03:43

contract so basically let's go step by

play03:46

step so mining yeah we got it there was

play03:49

no mining but we are going to do some

play03:51

computations today provides a proof of

play03:53

work to some smart contract that is

play03:55

already deployed on testnet and we are

play03:58

going to receive an nft as a reward from

play04:02

this computations that we did so

play04:04

technically this is kind of mining so

play04:07

let's go for it so what we will need we

play04:10

need a wallet we need repository we need

play04:12

developer environment so

play04:14

I hope you do have a wallet you got to

play04:17

install one of the apps that are

play04:19

suggested so it's either tone keeper to

play04:20

on HUB or maybe other non-custodial

play04:22

wallets I use for programming I use

play04:25

openmask but today I'm going to be using

play04:27

tone keeper as it suggests in this

play04:29

article

play04:30

so we will have to install tone keeper

play04:32

then we have to enable test mode in tone

play04:34

keeper so I hope you you are able to

play04:36

deal with that so please follow this

play04:38

link

play04:39

and enable the test mode on your tone

play04:42

keeper and project setup so we are going

play04:45

to start with some pre-built code let's

play04:47

see what it is

play04:49

alrighty so

play04:52

mining process it explains us which

play04:54

comments this smart contract understands

play04:57

okay so basically this is a source code

play05:00

of some smart contract that is already

play05:03

deployed in testnet and we are going to

play05:04

know the address of that smart contract

play05:07

I believe

play05:09

so um we'll just create create a new

play05:13

repository out of it

play05:15

we will call it

play05:17

um

play05:18

tone on boarding

play05:21

challenge

play05:23

why not that simple

play05:28

and uh yes it is getting cloned

play05:33

actually I would have to also clone with

play05:37

my machine

play05:39

let's see what it states development

play05:41

environment so there's Cloud versus

play05:42

local

play05:44

um I'm gonna go with local if you don't

play05:46

feel confident you can do it on cloud

play05:48

but

play05:49

my dream is that you personally would

play05:52

start programming on ton and that's why

play05:55

if you now go step by step with me then

play05:59

there's a big chance you're gonna get

play06:00

back to it again so that's why I'm not

play06:02

gonna go with local with Cloud I'm gonna

play06:04

go with local environment and

play06:07

um don't worry if if something doesn't

play06:10

work you can Outreach to me personally

play06:12

and I will help you okay so

play06:14

we're skipping this part with Cloud

play06:17

space the local environment so we'll

play06:19

need git node.js JavaScript idea I

play06:22

already have git installed if you don't

play06:23

just follow this link I already have

play06:25

node.js installed if you don't also

play06:27

follow this link and I I'm using vs code

play06:31

as a ede so I recommend it you can also

play06:35

use it so we'll have to go on this

play06:38

GitHub repository and open it so

play06:41

um I'm going to

play06:44

yeah I'm in my repository so I'm going

play06:47

to git clone

play06:50

Repository

play06:51

and then get into it

play06:56

and do yarn so we basically have to

play06:59

install all the packages that are

play07:02

offered to us so fancy compiler working

play07:05

with big numbers generating QR code the

play07:09

main tone library to interact with data

play07:13

that is consumed from the tone

play07:14

blockchain

play07:15

contract executor you're kind of

play07:17

emulating the process of TVM we're not

play07:20

going to touch that probably in this

play07:21

lesson but uh yeah in the typescript of

play07:24

course awesome

play07:25

so connect to tone so basically

play07:29

the flow is going to be as followed so

play07:31

we are going to connect to a Smart

play07:34

contract so smart contract is has

play07:36

certain data has a certain state of the

play07:38

data and we're going to connect with it

play07:41

get some information for mining like

play07:44

complexity and some values that we have

play07:47

to work with in order to mine a hash

play07:50

that would be less than complexity or

play07:52

bigger than complexity we'll check it

play07:53

out

play07:54

and then once we are once we got

play07:57

something that is bigger than complexity

play07:59

we are going to compose a message and

play08:02

send this message back into the smart

play08:05

contract so

play08:06

when we are trying to read data we are

play08:10

using API so it's not API of the actual

play08:13

blockchain it is like some server that

play08:16

is hosting a light node

play08:18

probably so light node is something like

play08:21

a node it's also a part of the network

play08:23

but it's not validating the transactions

play08:25

that are happening there it's like kind

play08:27

of syncing with uh with the blockchain

play08:32

it might be not the light node it

play08:34

depends on the server actually so it

play08:36

just syncs with the blockchain and this

play08:39

server is able to read data and give us

play08:41

the

play08:42

um answers to http requests through like

play08:45

RPC

play08:46

so uh basically to read that we will

play08:49

just need API to write it there we would

play08:52

need to send a transaction directly into

play08:55

the tone blockchain so that's why first

play08:58

step we read then we are doing mining

play09:01

some kind of computations and then we're

play09:03

using we composing a message and we send

play09:05

it into the blockchain

play09:06

so uh I forgot the best part we get an

play09:09

nft afterwards so

play09:12

um there is smart contract addresses

play09:14

that we need okay we need to add to

play09:16

addresses to to The Miner wallet address

play09:19

collection address

play09:21

great copy the address on get gems

play09:25

get gems

play09:27

yeah here's a test net of get gems and

play09:30

someone already got an nft wow

play09:33

I hope you're going to be the second

play09:34

ones cool so we need to copy the smart

play09:37

contract address I think this is the

play09:40

address of collection

play09:42

yes

play09:43

I'm going to copy it

play09:45

but actually first I would want to copy

play09:47

that code so the

play09:50

the guys who created this challenge for

play09:52

us the already pre-composed some code

play09:54

for us so what does this code do we

play09:57

basically import the address class from

play10:00

tone

play10:01

address class is going to help us to

play10:03

interact with data that is tone related

play10:06

so your wallet address so here you have

play10:09

to put the address of your tone keeper

play10:12

wallet on testnet this is mine

play10:16

you can send some testing coins there if

play10:19

you want to greet me so

play10:22

um this is my wallet and then the

play10:23

collection

play10:24

The Collection that's exactly this one

play10:26

address

play10:29

great so we almost finished the first

play10:31

step

play10:33

cheers

play10:35

why do we need this function so

play10:37

basically later on we are going to have

play10:39

some async

play10:41

functions that are going to be running

play10:43

that's why we are first announcing this

play10:46

we're defining this function and then we

play10:48

run it because it's async we don't care

play10:51

when it's going to end it's going to end

play10:53

uh

play10:54

in certain order finish its steps and we

play10:58

don't want to to get stuck on that so

play11:01

why do we need parts addresses yeah so

play11:05

here you understand that we are going to

play11:08

get a user friendly form

play11:12

uh

play11:13

Yeah we actually parse and address and

play11:15

then we are going to have different

play11:18

representations of an address that might

play11:20

be useful in the process

play11:22

so we connect to API provider

play11:25

so we're going to connect to tone Center

play11:27

API this is one of the providers so as I

play11:30

explained they are hosting a server that

play11:32

is talking to blockchain and the server

play11:35

is answering us with data

play11:39

and uh

play11:41

here it's asking us for an API key so

play11:46

probably now in the corner of the video

play11:48

you're gonna see a video on my channel

play11:50

there's gonna be a link to a video on my

play11:52

channel where I explain how to host own

play11:55

API that you like you could host own API

play12:00

that would

play12:01

um

play12:03

not require you to use an API key

play12:07

so

play12:08

uh but here we are going to probably

play12:12

just use

play12:14

um this we're going to probably uh just

play12:17

use this one also it's like

play12:21

it allows you to do 10 requests per

play12:23

second I think it's more than enough for

play12:25

us now but again as I said if you don't

play12:28

want this limitation you can just go uh

play12:30

to this video that I pointed out and you

play12:33

can spin up your own API instance

play12:36

and start working with it

play12:39

so first we need to get mining data from

play12:42

tone what kind of data are we going to

play12:44

get so get mining data

play12:48

and this is the first thing that you

play12:51

will learn about smart contracts so

play12:52

smart contracts have a getter function

play12:54

so basically there's a getter function

play12:57

that will return some specific data that

play13:01

is written in storage of of the

play13:04

available to Smart contract memory so we

play13:08

are going to get proof of work

play13:10

complexity we are going to get lost

play13:12

success seed Target delta mean CPL Max

play13:16

CPL those three we are not gonna need

play13:20

and how to run a method to any smart

play13:24

contract great so we're going to copy

play13:26

that code

play13:29

we're going to copy that code

play13:33

but also here we had to define the

play13:35

client

play13:37

foreign

play13:38

yes

play13:40

so we had to import the stone client

play13:42

from tone

play13:44

and we're going to just do it without

play13:47

the tone API key mining data so

play13:51

basically we established a client

play13:54

of connection to this RPC to this server

play13:59

and we are

play14:02

calling them the method called get

play14:04

method

play14:05

we set the address

play14:08

like from which I just want to call this

play14:10

get method and here we get get mining

play14:13

data this is the name of the getter

play14:15

method

play14:16

and let's consult what it's going to

play14:19

tell us

play14:22

test node

play14:24

index.s

play14:28

exactly this is what we wanted to get

play14:31

how much gas was used

play14:34

and the stack

play14:37

so here in in this article you can see

play14:40

some cool data about how to

play14:44

oh you could actually do just npm start

play14:47

npm Run start

play14:49

but let's see what was the function

play14:50

exactly it is not index TS

play14:54

so we get the same data great so we

play14:58

don't get this data at the moment we

play15:00

don't understand what exactly they mean

play15:02

but

play15:04

um if you want to learn about gas

play15:06

here you can read the few articles but

play15:10

basically it's not free to move things

play15:13

around on the blockchain you have to pay

play15:15

for each transaction even on tone even a

play15:18

smart contract has to kind of pay a rent

play15:20

for uh consuming the memory for storing

play15:25

the data on the blockchain so

play15:27

um if you want to learn more about it

play15:29

you can go to those links but we want to

play15:32

mine an nft today right so we have to

play15:35

import a library that would help us to

play15:37

interact with big numbers because those

play15:40

are big numbers

play15:42

so we're going to parse

play15:45

stake now

play15:47

so we don't need to consol that log

play15:49

anymore

play15:50

parse Tech num Okay so

play15:54

uh mining data

play16:00

okay so basically here we create a

play16:04

function into which we pass

play16:07

some part of the stack

play16:10

we create a big number instance

play16:13

and we convert it so let's just do this

play16:18

copy

play16:21

so we saved it and let's run our

play16:24

function again

play16:27

awesome so now we at least see

play16:30

what kind of a big number that is this

play16:33

is complexity and last success this is

play16:35

timestamp so this is a seed

play16:38

this phrase is going to be used by US

play16:40

for mining a hash

play16:43

okay

play16:44

as you can see mining data is like hex

play16:46

numbers exactly

play16:50

um that's exactly what we saw so we are

play16:52

doing good so complexity is the most

play16:54

important number for me minor

play16:57

um and

play16:59

seed is another one it's a unique value

play17:01

generated by smart contracts to

play17:03

calculate a hash

play17:05

great

play17:06

so we need to prepare an nft mentor

play17:10

we need to prepare a mining message

play17:12

this message as I told you before you

play17:15

are going to send once the once you find

play17:19

the proper uh hash so

play17:24

uh we need to import Unix now to work

play17:27

with

play17:28

data stamps

play17:30

okay

play17:32

we are importing that thing

play17:37

so

play17:40

basically

play17:42

the transaction Builder is already built

play17:44

for us

play17:46

and uh

play17:49

let's do it that way so if you really

play17:51

want to understand how this message was

play17:52

built I'm going to answer that at the

play17:55

end so we are going to run here at to do

play17:57

what we need to do at the end so

play18:01

uh

play18:03

first

play18:05

how does the query

play18:10

is mine

play18:13

is composing a message

play18:18

so um

play18:20

what are the

play18:22

au pair

play18:24

yes

play18:27

and data 2.

play18:31

Okay so

play18:35

we need to do nft minor so message we

play18:38

can post the message and finally it's

play18:41

the this article States finally a minor

play18:43

because actually now now we are going to

play18:47

start calculating hash so

play18:51

so we compose the message and we are

play18:53

going to actually get a hash from

play18:55

message so we first compose a message

play18:59

with

play19:00

um our wallet with data one for now it's

play19:04

going to be just a zero in BN format and

play19:08

the seed so the seed we received from

play19:11

the get mining data so yeah everything

play19:14

is going on the plan so we get mining

play19:16

data we get a seed

play19:19

we compose a message with with help of

play19:22

this seed

play19:24

and now we are going to

play19:28

set a while so while the the hash from

play19:32

the message the big number

play19:33

representation is not greater than

play19:36

complexity Yeah so basically as I said

play19:39

while it's not greater

play19:41

we're going to keep the the thing doing

play19:45

so we are doing

play19:48

mind params okay so

play19:52

this one

play19:54

is our object that we then pass into the

play19:58

Mind function

play20:00

and we will need to set the expire

play20:04

okay we get you we need actually Unix

play20:08

now to get the timestamp of the current

play20:10

moment

play20:11

data one so we have to just this is a

play20:14

big number way to add one

play20:18

to increment it by one then we again

play20:20

compose a message with help of the

play20:22

queries mine we can pause this message

play20:25

and once the message is going like this

play20:28

hash is going to be greater than

play20:30

complexity then we're actually going to

play20:32

send this message so

play20:36

all right so we are offered to put some

play20:38

beauty in here

play20:40

all right let's let's do it because we

play20:43

already understand how how the code

play20:45

works

play20:47

let's replace it with this more

play20:51

beautiful version of code great

play20:55

uh

play20:57

did anything change actually no we just

play21:00

changed so you see the main principles

play21:02

are working the same so we just changed

play21:04

the link so the incrementer is a

play21:08

progress then we clear the uh the

play21:10

console then we're writing some message

play21:12

yeah this is just a better user

play21:14

experience but again

play21:16

this is

play21:17

[Music]

play21:17

um

play21:18

so it also shows the last hash that we

play21:21

calculated

play21:22

so it's kind of it's kind of

play21:25

more beautiful I would say great we're

play21:28

gonna see soon how it works okay let's

play21:29

go for it

play21:31

you can do yarn starts

play21:37

okay so what just happened

play21:41

mining started please wait for 30 60

play21:44

seconds to mine your nft

play21:46

we mind

play21:47

863 hashes and the last one is this one

play21:50

Mission completed message hash is less

play21:53

than complexity found okay so we needed

play21:55

to actually find one that is less than

play21:58

proof of work complexity great we got

play22:01

the message hash we got the complexity

play22:02

it is smaller in the big number

play22:05

representation of course so we are done

play22:08

this is great so now we need to send

play22:11

this to Smart contracts so we need to

play22:12

prove that so now we have proof of work

play22:14

so basically we did some computations

play22:16

and this is our this hash this is our

play22:19

proof of work we found it and we are

play22:22

going to send it into the

play22:25

um smart contract that is supposed to

play22:27

check it and give us an nft if we are

play22:30

actually right on that

play22:32

great let's

play22:35

let's see how we build a payment link

play22:38

what is the payment link

play22:40

payment URL okay I think I will open you

play22:44

a little secret here so

play22:47

um

play22:48

in tone every message it is a payment so

play22:53

you would have to send messages so

play22:56

you're sending message with some value

play22:58

with some coins and then you also attach

play23:00

some data in a certain order and if you

play23:03

want to dig deeper into the order that

play23:05

you attach data to a message in stay

play23:08

tuned we're going to talk about this at

play23:10

the end when we're talking about how to

play23:12

how this message is composed under the

play23:15

who so

play23:16

every message is a payment so that's why

play23:19

it says build a payment link and what

play23:22

we're going to do we are going to

play23:24

package a transaction

play23:26

and then with our wallet why we need the

play23:28

wallet we are going to sign this

play23:31

transaction of sending

play23:33

some some money and our information

play23:35

we're going to send it to the address of

play23:37

smart contract which this collection

play23:40

which holds this collection of nfts that

play23:42

we we will get from the uh from this

play23:46

getjams collection

play23:49

uh no good gems actually it's for

play23:51

everyone it's just listed on the gems I

play23:53

want to be very specific on that on uh

play23:55

pretty much on everything so uh

play23:58

great so now we are going to uh

play24:03

we are going to copy that code and see

play24:06

what exactly

play24:09

happens there

play24:10

nice so just so you understand at this

play24:13

moment we already found the hash so

play24:16

message we already found the math we

play24:18

basically composed the message which

play24:20

hash is good enough to get this nft we

play24:23

have a proof of work so as soon as you

play24:25

find the hash you should quickly ma make

play24:27

a transaction okay if someone else makes

play24:30

a transaction the C changes and you have

play24:32

to find a hash again okay so basically

play24:35

once we make this transaction we send

play24:37

this newly found hash we send it and we

play24:41

get the nft the seed is going to change

play24:43

inside of the smart contract and when

play24:45

someone else is running the first step

play24:48

and getting this

play24:50

get data from the smart contract it will

play24:53

get a different seeds so if and and also

play24:56

once we if we got the old one and we

play24:59

send our transaction with uh with a hash

play25:02

that was calculated with the old seed

play25:03

it's not going to get confirmed because

play25:05

there's also check on the smart contract

play25:07

side so

play25:08

this is good for understanding

play25:11

great to Nano needs to be imported from

play25:14

tone

play25:15

this is basically we so One Tone

play25:18

consists of the

play25:20

one and and nine zeros amount of Nanos

play25:25

inside of the tone so basically if we

play25:27

want to say

play25:29

0.05 tons this is actually we need to

play25:32

transform it to Nana because all the

play25:34

calculations when the programming are

play25:35

going in Nanos so we need to transform

play25:38

this into Nano and Nano is a big number

play25:41

of course because it's like nine zeros

play25:42

wow I wish my celery had not zeros

play25:46

in some countries it would it would

play25:49

so we prepare body cell

play25:52

okay message to b o c body cell

play25:57

to string

play25:59

okay it's getting interesting here

play26:02

and then we do a link we create a link

play26:06

for the transfer and

play26:09

we are transferred to some address with

play26:12

certain amount

play26:14

and being been

play26:18

where do we get bin from

play26:21

okay Bean is just a part of the URL body

play26:24

so great

play26:27

we basically have to create a body cell

play26:30

and uh

play26:32

in a certain format

play26:34

put it on the URL and we get a link

play26:38

so basically

play26:39

let me let me run that thing

play26:53

so basically uh

play27:01

okay okay two sometime and here we have

play27:06

this link

play27:08

okay I yeah here we have the address

play27:10

this is the address of collection

play27:13

here we have the amount so we give some

play27:18

well where we set the amount where do we

play27:20

pack the message

play27:23

we pack the message

play27:27

okay

play27:30

I want to see where we set the amount

play27:35

yeah here we set amount to send

play27:38

we sent just enough money to deliver

play27:41

that message to the smart contract and

play27:44

the smart contract is going to

play27:46

so basically the network is going to eat

play27:48

part of that payment that we send and

play27:50

then we're going to get it back so

play27:51

because like Fair smart contracts they

play27:54

do it like they require you to put

play27:56

enough money so the transaction would be

play27:58

delivered you can actually put as much

play28:00

money as you want but they will return

play28:02

you everything that was not used for the

play28:03

transaction so basically you provide

play28:06

them money that would be enough for the

play28:08

Sending message delivering it to a Smart

play28:11

contract and then getting it back to

play28:13

getting if getting the nft actually back

play28:16

if the smart contract would also want to

play28:19

charge you for getting this nft then

play28:21

they would also require you to send much

play28:23

more money and return you everything

play28:25

that was left after getting the price of

play28:28

nft

play28:30

payment one way and then they would just

play28:33

send it back probably with forcing you

play28:36

to pay for the last transaction but if

play28:39

you stay long enough if you subscribe to

play28:41

my channel you will learn more of these

play28:42

Concepts soon but today we actually want

play28:45

to understand

play28:48

body cell okay let's talk about this at

play28:51

the end

play28:53

what

play28:54

in the world

play28:57

is a boc co-pilot is is good at hinting

play29:01

on these things so

play29:02

let's go for it and uh this is a link to

play29:08

transaction that we need to actually

play29:09

sign

play29:11

convert link to smartphone great so

play29:15

it is we have to generate some QR code

play29:17

so I I would I would be able to kind of

play29:19

scan it with my tone keeper and sign

play29:22

this transaction with my coins that I

play29:24

have on my testnet wallet so uh I will

play29:27

do yarn add

play29:30

QR code terminal

play29:33

and uh here I would have to

play29:37

kind of import it

play29:40

okay

play29:42

and I would have to generate a QR code

play29:46

even better

play29:50

so this all has have to still be

play29:54

I'm not gonna console it yeah and this

play29:57

I'm gonna console

play29:59

great so I'm going to do yarn

play30:04

start

play30:18

sometimes it takes time you see this is

play30:20

that's why it's called proof of work

play30:22

alrighty and now I have a QR code that I

play30:25

could actually scan while it's in test

play30:28

net mode and I would sign a transaction

play30:31

so before I scan it and I sign the

play30:35

transaction on my device because

play30:38

quick and quick and bad so why it's

play30:42

non-custodial wallet because your seed

play30:44

phrase that you use to generate the

play30:47

disconnect with your private key and

play30:48

you're using it to sign every

play30:49

transaction it's only on your device

play30:51

that's why your phones are secured no

play30:54

one can write a transaction to a network

play30:55

on your behalf so basically you are

play30:59

signing every transaction on your wallet

play31:02

and then you send the result like the

play31:05

signed transaction you send it to the

play31:06

back end of testnet of the tone keeper

play31:09

and uh this transaction is pushed to

play31:13

closest validator and it's actually

play31:15

after it's validated that actually you

play31:18

signed that transaction

play31:20

so it gets on the blockchain no one can

play31:24

sign transaction but you tomkeeper

play31:26

doesn't know your seed phrase and that's

play31:29

why we we could compose the whole

play31:31

transaction here but once we scan a QR

play31:34

code you could see that in this URL

play31:36

there is a string representation of this

play31:40

uh cell that like oh there is a string

play31:44

representation of a cell that stores a

play31:46

message that we want to actually send to

play31:49

the smart contract that is going to give

play31:50

us nft great

play31:54

um

play31:55

so what I'm gonna do is now I'm going to

play31:58

scan this

play32:01

I'm going to scan this QR code I'm

play32:03

actually getting a little bit excited

play32:05

about that

play32:06

all right so

play32:10

let's see

play32:15

okay

play32:19

if you want to see exactly what happens

play32:21

on my screen you should actually go and

play32:23

try to

play32:25

follow these actions all right so

play32:29

I sent let's I will show you another

play32:33

secret so

play32:34

there is a test net tonescan.org

play32:38

and this is a Explorer we can see

play32:40

everything that happens on the

play32:42

blockchain with that if you remember I

play32:45

have put my address here this is my

play32:48

wallet address

play32:49

and we can see if there was any

play32:53

yes I actually got two coins and we kind

play32:58

of missed that part

play33:00

we missed that part where you were

play33:02

actually supposed to go and get the test

play33:04

net coins because you wouldn't be able

play33:07

to sign a transaction

play33:08

unless you have a test net coins

play33:12

um

play33:14

prepare

play33:16

test net coins we didn't get any test

play33:20

net coins let's fix it quickly so you

play33:23

need to uh

play33:25

go to

play33:28

file set

play33:29

yes this is a test net coins file set

play33:33

and here follow the steps how to get

play33:37

these test coins on it's free it's

play33:39

completely free as I said this is

play33:41

testnet it's this money is like Monopoly

play33:43

money it's you can play around with it

play33:45

and not tone tone is not Monopoly money

play33:51

and

play33:53

once you get these test net coins you

play33:55

would be able to sign transactions just

play33:57

like I did so I did a transaction

play34:01

I did a transaction uh one minute ago

play34:05

and it actually went well

play34:07

yeah so I probably cannot see the

play34:12

in this Explorer I cannot see the data

play34:15

that was sent

play34:19

yeah I could see a hash

play34:22

and I could see operation just a small

play34:25

phone

play34:27

okay it's not it's not that thing

play34:31

so uh

play34:35

oh wait actually

play34:41

yeah that's that was the fun that I

play34:43

wanted to show you like this is

play34:45

Operation so operation is mine so we

play34:48

actually send the separation that we

play34:49

want to mine it and um great

play34:54

uh let me get back to what got here so

play34:57

we signed the transaction

play35:00

we sent it

play35:02

and we got back nothing empty how do we

play35:07

check that things worked out

play35:10

we need to get the address and go to get

play35:14

gems

play35:15

oh

play35:17

we need to go to actual

play35:20

uh okay I just wanted to see the URL

play35:23

structure so I want to see to go like to

play35:27

okay so you can see this is my address

play35:30

and I just got an nft

play35:33

I just got an nft this works this works

play35:37

and this rocket is US flying to the moon

play35:41

right now

play35:42

so

play35:43

guys I'm going to sell that nft on the

play35:47

test net

play35:48

but I'm going to record another video

play35:50

about that how to sell your nfts and

play35:53

let's play around on testnet but this is

play35:55

number two and everyone should know that

play35:58

it's mine I'm going to make an offer so

play36:02

if someone wants to get it for 100

play36:05

it's going to be

play36:07

let's do four in two weeks

play36:10

oh 100 tone I'm gonna sell this nft okay

play36:14

it's asking me to connect wallet I'm not

play36:16

gonna do it right now

play36:18

so basically it worked it worked we got

play36:22

an nft on this address

play36:25

so this nft

play36:27

actually came

play36:29

with this transaction so we send

play36:32

something out

play36:34

and we actually got

play36:36

nft back

play36:39

which is great we got no money in return

play36:42

actually

play36:43

I'm not sure why

play36:45

we could read the the code of the smart

play36:47

contract

play36:49

so we only use this index file

play36:53

we coded repeated step by step

play36:56

everything and we got an nft

play37:00

we still didn't write any smart

play37:01

contracts but as I promised

play37:04

we are going to go through two very

play37:09

important things now

play37:10

as you could remember

play37:12

we have

play37:15

yes we have tried

play37:19

uh

play37:21

let me find it the body cell the message

play37:24

body cell

play37:26

yeah and here we are actually composing

play37:29

it amount to sand

play37:32

collection address where is the message

play37:34

we're composing yeah queries dot Mine

play37:38

and queries so the only two things we

play37:41

don't know how they work is mind message

play37:44

params and this is just a type so just a

play37:47

type that tells us

play37:48

what is the data that we're going to

play37:50

read from the smart contract so and this

play37:54

is queries so there's like all possible

play37:57

queries that this smart contract

play37:58

understands

play38:00

and uh it actually you see this method

play38:05

like queries mine it gets params that

play38:08

are like mind message params and it

play38:11

returns a cell because cell is a this is

play38:15

something that you will understand you

play38:17

will have to understand and I've seen

play38:19

here a little bit of a description maybe

play38:21

a link for you to to get more about it

play38:24

it is uh

play38:29

yes I've seen this notice here

play38:35

what is this cell what the cell yeah so

play38:39

cell is a data structure in tone and uh

play38:44

so basically cell is a cell of memory so

play38:48

in the TVM there is a lot of cells that

play38:51

are storing something and uh once we

play38:55

send a message and this message is

play38:56

accepted by TVM its contents are kind of

play38:59

saved to the cell so we are composing

play39:03

that cell on our side and then once it

play39:06

gets to the TVM it actually gets into

play39:08

the gets into the self

play39:10

so uh we want to understand how this

play39:14

cell was constructed how how in the

play39:16

world we get this data

play39:18

and

play39:19

at the end you can see here we get a

play39:23

cell so let's get into it

play39:27

so we have a mine function okay so and

play39:31

here begins interesting part where we

play39:33

actually work with the

play39:36

Concepts entities of actual tone before

play39:39

it was just node.js through API we're

play39:42

getting getter method we understood what

play39:43

a smart contract but here we actually

play39:45

here's the hard part the one that you

play39:48

will actually have to learn and for that

play39:50

I'm going to record some more videos and

play39:53

I already have some on my channel but

play39:55

here with help of a typescript we are

play39:57

composing a concept of cell they're

play40:00

going to then package and send it into

play40:01

the TVM so we begin sell

play40:06

and then we write a code operation code

play40:09

which is my you see like if we go into

play40:12

what what it is

play40:14

this is exactly what we got here on the

play40:17

test net

play40:18

you see like this is the operation code

play40:20

so we told so we send some money to a

play40:23

Smart contract and we said the operation

play40:25

that you need to to perform now is this

play40:28

this hexa code

play40:31

then we write the expire

play40:34

okay

play40:36

then we write so we basically in this

play40:39

cell we are kind of putting like imagine

play40:41

a box and you are putting the chocolate

play40:43

bars into it so the first chocolate bar

play40:45

was milka the second one was also milka

play40:49

so basically this is a you in so we

play40:52

Define how much space it's going to take

play40:54

so we Define what kind of stuff is

play40:57

written there how much space it's going

play40:59

to take in bytes then again what kind of

play41:02

stuff is going to be you int how much

play41:04

space then we say it's going to be

play41:06

address and here we pass mint2 let's see

play41:11

what kind of mint 2 we are providing

play41:13

here mind params this means to wallet so

play41:17

we we pass our address that we actually

play41:20

defined here

play41:21

and uh

play41:23

we put this address already into the

play41:26

cell so in this box with chocolate bars

play41:28

and then we write more units more units

play41:32

we say how much it's gonna space gonna

play41:35

take and uh then we just and sell and we

play41:38

return it so

play41:39

basically

play41:41

queries mine is just composing a cell

play41:44

with all the necessary data

play41:47

and

play41:49

then it helps us and it we send this

play41:52

cell into the smart contract so

play41:56

my you might be kind of uh a little bit

play42:00

confused like we're programming with

play42:02

tone here's typescript some hexadecimal

play42:06

numbers and I want to just encourage you

play42:09

stay very patient about that because

play42:11

you're going to

play42:14

encounter at least two programming

play42:16

languages while working with tone

play42:18

programming this is typescript

play42:20

Javascript and fancy at least hopefully

play42:24

I pray God and I hope that once you're

play42:27

watching this video

play42:28

you're already able to write smart

play42:32

contracts intact that's some language

play42:34

that is not yet working but fancy this

play42:37

is something that

play42:38

you are going to use so I I like the I

play42:42

like to use the allegory that uh smart

play42:46

contract itself is like a satellite so

play42:50

and the satellite is brought to the to

play42:53

the space where it goes around the globe

play42:56

it's brought there with rockets so

play42:58

typescript is kind of a rockets that are

play43:02

bringing the satellite to the orbit to

play43:05

go around the globe

play43:06

and at some point they fall off so we

play43:09

don't need type script on the TVM at all

play43:11

because TVM has no idea what is

play43:13

typescript and uh that's why because the

play43:18

the the data that we're sending or the

play43:21

smart contract itself when we deploying

play43:23

it

play43:24

uh because uh it is going to be run on

play43:29

the machines on the network of machines

play43:32

we have to keep the low context so

play43:36

that's why you will have to deal with

play43:37

bytes you will have to deal with Stacks

play43:39

you will have to plan how you're using

play43:43

your memory like how you're packing this

play43:45

cell so the smart contract would

play43:46

actually understand it and would know

play43:48

what to do with this data and how to

play43:50

read it and unpack it stuff so

play43:53

um I think this was a very useful video

play43:56

when you first encountered like the

play43:58

beginning of it like at the beginning

play44:00

the first concepts of something you

play44:02

could get at nft so you understand

play44:04

you're not that scared of tone anymore

play44:06

and that means that now you're ready to

play44:09

go to the

play44:11

document documentation website and just

play44:14

uh read getting started maybe who knows

play44:17

maybe soon you'll write your first smart

play44:18

contract if you're not sure about that

play44:20

and you want to watch more videos you

play44:22

you know like there is more on my

play44:24

channel and uh I'm doing office hours

play44:28

um I'm trying to do it as often as

play44:30

possible so

play44:32

um you will see it on my channel as well

play44:34

so I would be very happy to maybe Mentor

play44:37

you or guide you through some issues

play44:39

that you're going to encounter but in

play44:41

general I think this was a good start

play44:43

for you and I wish you a very good luck

play44:46

I hope you're going to build a very

play44:48

awesome product Anton I really hope on

play44:50

that and uh

play44:53

we all together are going to help you

play44:55

don't worry there is a chat that is like

play44:58

uh for a lot of developers you can ask

play45:00

smart questions and also you can ask

play45:02

their dumb questions my favorite ones

play45:04

because 99 of mine are dumb and uh I

play45:09

encourage you to go there I encourage

play45:11

you to try it fall if you didn't do any

play45:14

steps right now while I was

play45:16

showing that to you please do it will

play45:18

take you so how much 20 minutes and um

play45:21

you get your nft on the stand but you

play45:23

also get your hands on actual coding so

play45:26

um I hope you succeed man I hope you

play45:28

succeed and you will so thank you very

play45:31

much it was amazing time with you and uh

play45:35

I hope to see you soon ciao

Rate This

5.0 / 5 (0 votes)

Related Tags
智能合约区块链编程TON区块链NFT挖矿开发者教程测试网络技术挑战加密货币编程入门Mark频道
Do you need a summary in English?