驾驭makefile_驾驭Web 3.0浪潮

驾驭makefile

‘Mastering Web 3.0 with Waves’. “用Waves掌握Web 3.0”的经验

你的背景是什么? 是什么促使您参加该课程的? (What is your background? What motivated you to take the course?)

I’ve been a web developer for about 15 years, working mostly as a freelancer.

我从事Web开发大约15年,主要是作为自由职业者。

Working on the development of sustainable registry web application for emerging countries, financed by a bank group, I was once asked about the possibility of implementing blockchain certification into the registry. At that time, I didn’t know much about blockchain certification even though I had been into crypto for a while, mostly on the investor side.

在一个银行集团的资助下,我致力于为新兴国家开发可持续的注册表Web应用程序,曾经有人问我是否有可能在注册表中实施区块链认证。 那时,尽管我已经进入加密领域一段时间了,但我对区块链认证的了解并不多,主要是在投资者方面。

We didn’t push through with the implementation of that feature on that specific application but the idea that institutions and banks were asking about implementing such technologies in their applications made me do a lot of study and research into the topic and then start the Signature Chain project.

我们没有在特定的应用程序上实施该功能,但是机构和银行要求在其应用程序中实施此类技术的想法使我对该主题进行了大量研究和研究,然后启动了签名链。项目。

I developed a beta version that is already live on Mainnet. At that time [Waves programming language] Ride wasn’t ready yet, so I developed it in the simplest way, using transfer transactions with attached JSON. But the main goal has always been to deliver more advanced features once Ride was available. And this was the main reason for me to take the course, since the next planned step for the project is turning it into a decentralised application (dApp).

我开发了一个Beta版本,该版本已经在Mainnet上发布。 当时[Waves编程语言] Ride还没有准备好,所以我以最简单的方式开发了它,使用带有附加JSON的传输事务。 但是,主要目标始终是在Ride可用后提供更高级的功能。 这是我选择这门课程的主要原因,因为该项目的下一个计划步骤是将其转变为分布式应用程序(dApp)。

您发现课程的哪些方面最容易,最困难? (What aspects of the course did you find the easiest and most difficult?)

The easiest aspect was that we had plenty of time to do it, that it was about just learning rather than competing to be the best. It was also well explained, with simple but explicit illustrations which helped a lot to visualise and understand different topics.

最简单的方面是我们有足够的时间去做,这是关于学习而不是争夺最好的。 它也得到了很好的解释,并提供了简单但明确的插图,极大地帮助了可视化和理解了不同的主题。

In the challenges, we were pushed to think on our own and sometimes do some research, which is the best way to learn and get a stronger understanding of concepts from a lesson.

在挑战中,我们被迫独自思考,有时会做一些研究,这是学习和从课程中获得对概念的更深刻理解的最佳方法。

Several times, I didn’t have a clear understanding from the lecture part until I got into the code and went through the challenge. No ‘copy/paste’ was allowed, which forced us to write all the challenge code, and that was another important point in reinforcing understanding.

有几次,直到我进入代码并接受挑战之后,我才对授课部分没有一个清晰的了解。 不允许“复制/粘贴”,这迫使我们编写所有挑战代码,这是加强理解的另一个重要方面。

The most difficult part was that sometimes multiple-choice questions in the challenge part were not that clear. I mean, my English isn’t excellent, and the questions were written by a non-native English speaker, so there was a gap in understanding sometimes.

最困难的部分是,挑战部分中的多项选择问题有时并不清楚。 我的意思是,我的英语水平不是很好,而且问题是由非英语母语的人撰写的,因此有时在理解上存在差距。

Probably, I would have liked to learn more from the oracle and NFT sections. But, in any case, this course mainly aims to hook developers in, and you definitely need to spend time playing around with it and practising later to really get a full understanding of every aspect and detail.

可能我想从oracle和NFT部分中学习更多。 但是,无论如何,本课程的主要目的是吸引开发人员,并且您绝对需要花时间玩弄它,以后再练习,以真正全面地了解每个方面和细节。

您能否详细讨论您在课程中使用的解决方案-“ Coupon Bazaar”? 您还可以提供代码示例吗? (Could you discuss in detail the solution you worked on during the course – ‘Coupon Bazaar’? Could you also provide examples of code?)

We worked on ‘Coupon Bazaar’, which is basically a marketplace where people buy and sell discount coupons for goods and services at a low price. Each coupon was represented by a digital asset, which also represented a special discount offered by suppliers.

我们在“ Coupon Bazaar”上工作,该市场基本上是人们以低价买卖商品和服务的折扣券的市场。 每个优惠券都由一种数字资产表示,该数字资产还代表了供应商提供的特殊折扣。

Work was required on several components of the application. First, it had to allow suppliers to register and manage their items (coupons). Then, a purchase confirmation feature needed to be created, as well as a feature enabling customers to search for and purchase coupons.

需要在应用程序的多个组件上进行工作。 首先,它必须允许供应商注册和管理其物品(优惠券)。 然后,需要创建购买确认功能,以及使客户能够搜索和购买优惠券的功能。

Several extra features were also added during the course, including a voting system and a feature for verification and blacklisting of suppliers.

在课程中还添加了一些额外的功能,包括投票系统以及用于验证和将供应商列入黑名单的功能。

We first went through differences between Smart Assets, Smart Accounts and dApp accounts, and the fundamentals of working with verifier functions. Verifier functions allow changing the default behavior of an account. By default, they check signatures of transactions, but the verifier function allows you to set another ‘rule’.

我们首先了解了智能资产,智能帐户和dApp帐户之间的区别,以及使用验证程序功能的基础。 验证程序功能允许更改帐户的默认行为。 默认情况下,它们检查交易的签名,但是验证程序功能允许您设置另一个“规则”。

{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
letownerPublicKey = base58'H8ndsHjBha6oJBQQx33zqbP5wi8sQP7hwgjzWUv3q95M'
@Verifier(tx)
funcverify() = {
    matchtx {
        cases: SetScriptTransaction=>sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey)
        cased: DataTransaction=>true
        case_ =>false
    }
}

Then we started adding items. We used one of the most important features for dApp development that allows any type of data to be recorded onto the blockchain as key-value pairs, the data transaction. We combined it with a new transaction, invokeScript, used to call a callable function into a dApp from the outside.

然后我们开始添加项目。 我们为dApp开发使用了最重要的功能之一,该功能允许将任何类型的数据作为键值对(即数据交易)记录到区块链上。 我们将其与新事务(invokeScript)结合使用,该事务用于从外部将可调用函数调用到dApp中。

One type of data transaction we used in the course was for suppliers to add items to the marketplace:

我们在本课程中使用的一种数据交易类型是供供应商向市场添加商品:

letdatajson = {
    "title":        "t-shirt with , vote 1",
    "coupon_price": 10000000,
    "old_price":    1000000000,
    "new_price":    100000000,
    "address":      "Universe",
    "description":  "I want you to make love, not war, i know you've heard it before",
    "image":        "https://bit.ly/2EXTghg"
}
it('add item', asyncfunction(){
    letts = invokeScript({
       dApp: dappAddress,
           call:{
               function:"addItem",
               args:[
                    { type:"string", value: datajson.title },
                    { type:"integer", value: datajson.coupon_price },
                    { type:"string", value: JSON.stringify(datajson) }
               ]},
               payment: []
           }, accountSupplierSeed)
    lettx = awaitbroadcast(ts)
    awaitwaitForTx(tx.id)
})

To process that data transaction through the addItem function and later develop a purchase and other options, we went through the callable function, able to be called by users from the outside. As a result, it can perform various tasks, such as initiating transfer of funds, writing or updating data in the dApp’s data storage, etc.

为了通过addItem函数处理该数据交易并随后开发购买和其他选项,我们经历了可调用函数,该函数可以由外部用户调用。 结果,它可以执行各种任务,例如启动资金转移,在dApp的数据存储中写入或更新数据等。

Here is an example of a callable function. It is used for the addItem function:

这是一个可调用函数的示例。 它用于addItem函数:

@Callable(i)
funcaddItem(title: String, price: Int, data: String) = {
    letsupplierAddress = toBase58String(i.caller.bytes)
    letitem = getKeyItem(supplierAddress, title)
    if( price <= 0) thenthrow("purchase amount cannot be less than item price")
    elseif( getValueItemSupplier(item) !=NONE ) thenthrow("an item is already exist")
    else{
        WriteSet([
           DataEntry(getKeyItemSupplier(item), supplierAddress),
           DataEntry(getKeyItemPrice(item), price),
           DataEntry(getKeyItemData(item), data)
        ])
    }
}

We later worked on a voting system to allow users to vote for promotion or removal of certain products. It used a ‘Commit-Reveal’ scheme to avoid outside influence during the voting process.

后来,我们开发了一种投票系统,允许用户对某些产品的促销或删除进行投票。 它采用了“公开披露”方案,以避免投票过程中的外部影响。

The commit step was used to collect encrypted votes with a hash function and salt.

提交步骤用于通过哈希函数和盐收集加密的投票。

The reveal step is for collecting decrypted votes and comparing their hashes.

揭示步骤是收集解密的选票并比较其哈希值。

Here is an example of a callable function used for this feature:

这是用于此功能的可调用函数的示例:

@Callable(i)
funcvoteCommit(item: String, hash: String) = {
    letuser = toBase58String(i.caller.bytes)
    letcommits = getValueCommitsCount(item)
    letstatus = getValueItemStatus(item)
    if( commits >=VOTERS) thenthrow("reached max num of voters")
    elseif(getValueCommit(item, user) !=NONE) thenthrow("user has already participated")
    elseif(getKeyItemSupplier(item) ==NONE) thenthrow("item does not exist")
    elseif(status !=NONE && status !=VOTING) thenthrow("voting is not possible")
    else{
        WriteSet([
           DataEntry(getKeyCommit(item, user), hash),
           DataEntry(getKeyCommitsCount(item), commits +1),
           DataEntry(getKeyItemStatus(item),if(commits ==VOTERS) thenREVEAL elseVOTING)
        ])
    }
}

您从本课程中学到了什么? (What else did you learn from the course?)

The course also touched upon tokenisation and non-fungible tokens (NFTs) – tokens that represent something unique and are therefore not interchangeable.

本课程还涉及令牌化和不可替代令牌(NFT)-令牌代表唯一的事物,因此不可互换。

The last class focused on the use of oracles. Since a blockchain cannot access data from the outside world, we need to use oracles that send real-world data to the blockchain.

最后一堂课的重点是使用oracle。 由于区块链无法访问来自外部世界的数据,因此我们需要使用将实际数据发送到区块链的oracle。

In the scope of our marketplace, we used an oracle to verify and, if necessary, blacklist a supplier that, for instance, didn't accept a previously sold coupon.

在我们的市场范围内,我们使用了一个预言机来进行验证,并在必要时将不接受先前出售的优惠券的供应商列入黑名单。

Here is a code example:

这是一个代码示例:

funcgetExtValueItemWhiteListStatus(item:String) = {
    item +"_verifier_status"
}
 
letverifier = "3Mx9qgMyMhHt7WUZr6PsaXNfmydxMG7YMxv"
letVERIFIED = "verified"
letBLACKLISTED = "blacklist"
@Callable(i)
funcsetstatus(supplier: String, status: String) = {
    letaccount = toBase58String(i.caller.bytes)
    if( account !=verifier ) thenthrow("only oracle verifier are able to manage whitelist")
    elseif( status !=VERIFIED && status !=BLACKLISTED) thenthrow("wrong status")
    else{
        WriteSet([
           DataEntry(getExtValueItemWhiteListStatus(supplier), status)
        ])
    }
}

您觉得课程的哪一部分最有用? (What part(s) of the course did you find most useful?)

The most useful part was the challenges. They made the lectures clearer and solidified my newly-acquired knowledge by trial and error. Practising with the IDE, explorer and oracles was really useful.

最有用的部分是挑战。 他们通过反复试验使讲座更加清晰,并巩固了我新近获得的知识。 使用IDE资源管理器oracle进行练习非常有用。

您打算如何使用从课程中学到的知识? (How do you plan to use what you learned from the course?)

From the beginning, this course was supposed to help bring my project to the next level. So, the idea is now to rewrite sign-web.app on Ride. The current version already offers working features for document certification, but it will definitely be enhanced with a future Ride version. It will allow more flexibility and clarity and more features, including email certification, multi-party agreement, etc.

从一开始,本课程就应该有助于将我的项目提高到一个新的水平。 因此,现在的想法是在Ride上重写sign-web.app 。 当前版本已经提供了用于文档认证的有效功能,但是将来的Ride版本肯定会对其进行增强。 它将提供更大的灵活性和清晰度,以及更多功能,包括电子邮件认证,多方协议等。

The course was also very mind-opening, and many ideas started to pop up in my head. I'm sure that more will come out of it in the future.

这门课程也非常开放,许多想法开始浮现在脑海。 我确信将来还会有更多的收获。

翻译自: https://habr.com/en/company/waves/blog/462991/

驾驭makefile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值