文章目录

  • Day1课程
    • 学习web 3
    • 资源
      • AssemblyScript
      • Rust
    • 阅读 web3 任务
      • SputnikDAO
      • 多签合约(Multisig-Contract)
        • MultiSig合约有什么好处呢?
      • Whitelist
      • Counter

Day1课程

官方课程链接: https://learnnear.club/lessons/day-1-reading-web3-ncdl1c4/
https://hackmd.io/@nearly-learning

学习web 3

学习阅读控制金钱,身份和所有权的合约。

今天的目标是阅读尽可能多的合约。

有时人们不确定如何完成此活动。 这些技巧可能会有所帮助。

Try to figure out how to get to the contract code. Then move to quickly read the code. You want to see as much as you can. Ask yourself about the “purpose” of the contract (why is it?) and “code” (what is it?)

尝试弄清楚如何获得合约代码。 然后移动以快速阅读代码。 您希望看到尽可能多的东西。 问问自己合约的“目的”(why is it?)和“代码”(what is it?)

  • AssemblyScript合约 是以.ts结尾的文件,通常是main.ts或index.ts
  • Rust合约 始终位于名为lib.rs的文件中。

核心活动:

  1. 在进行其他操作之前,请先观看此视频
  2. 在下面的资源部分中,选择AssemblyScript或Rust
    查看您的语言标记为“CORE Activity”的所有3份合约

奖励活动:
clone所选语言的 starter 库并按照说明进行操作

  • AssemblyScript
  • Rust (still under development)

Remember to focus on READING and avoid the temptation to build and run everything along the way because it’s a distraction at this point. You can build and run everything tomorrow.
你阅读得越多越好,如果可以的话,继续读下去。记住要把注意力集中在阅读上,避免一路上构建和运行所有东西的诱惑,因为这会分散你的注意力。你明天就可以建立和运行一切。

Read ALL the contracts for your language of choice, not just 3
阅读你所选择的语言的所有合约,而不仅仅是3种

Read all the contracts from the OTHER language as well.
还要阅读其他语言的所有合约。

Check out these little puzzles, they may be fun for you
查看这些小难题,它们可能对您很有趣

  • Scavenger Hunt Challenge #1
  • Scavenger Hunt Challenge #2

Going Deeper
If you’re feeling fearless, here’s about as far as you might take this road in a day

Review all core-contracts and watch related Live Contract Review videos
Review Illia’s contract repo
Review all Rainbow Hackathon contract submissions

资源

记住:今天的活动

  • 您无需构建和测试每个合同
  • 您无需了解每一行代码
  • 您应该像看艺术或听音乐一样简单地阅读合约,而不必担心每个点或内容

AssemblyScript

如果您打算专注于AssemblyScript,请打开AssemblyScript合约列表

您应该至少阅读3个标记为CORE活动的合约。

Rust

如果您打算专注于Rust,请打开Rust合约列表

您应该至少阅读3个标记为CORE活动的合约。

您可以阅读有关Rust合约基础的更多信息,也可以观看视频。

阅读 web3 任务

Please submit:

  • Contract name
  • What did you find most excited about it
  • What is the most challenging par to understand

根据原文提醒,填写如上信息到原文表单中,提交,任务完成。


相关项目如下:

Name Notes Code
SputnikDAO This contract is a simple version of a DAO to give out tips, bounties and grants. Allows anyone to send a proposal to reward other people with funds and get a council to vote for it. The major difference between this and Moloch DAO design is that this contract would receive its function via donation and council has equal rights. https://github.com/VitalPointAI/SputnikDao-AS-Contract/tree/main/sputnikdao-as
Multisig This contract provides a multisig scheme that allows making transfers, calling functions and adding / removing keys https://github.com/VitalPointAI/Multisig-Contract
Whitelist The purpose of this contract is to maintain the whitelist of the staking pool contracts account IDs that are approved by NEAR Foundation. https://github.com/VitalPointAI/Whitelist-Contract
Counter This contract implements simple counter backed by storage on blockchain. https://github.com/near-examples/counter
Guest Book Sign in with NEAR and add a message to the guest book https://github.com/near-examples/guest-book
Cross Contract Calls This repo is organized around a series of lessons about making cross contract calls https://github.com/near-examples/cross-contract-calls
NEAR Collection Examples This repository serves to demonstrate differences in gas consumption when storing or retrieving data from the NEAR blockchain using AssemblyScript collection methods found in near-sdk-as. https://github.com/near-examples/collection-examples-as
NEAR AssemblyScript Workshop This workshop includes several activities that introduce the basic concepts of writing contracts for NEAR Protocol using AssemblyScript https://github.com/near-examples/workshop–exploring-assemblyscript-contracts
NEAR Ice Cream This dApp demonstrates buying ice cream with NEAR tokens https://github.com/near/near-icecream
Crypto Corgis This dApp is an implementation of Crypto Kitties for NEAR https://github.com/nearprotocol/corgis
SputnikDAO Factory This contract is a factory that creates instances of SputnikDAO https://github.com/VitalPointAI/SputnikDao-AS-Contract/tree/main/sputnikdao-as-factory
Voting Port of NEAR core-contract as AssemblyScript https://github.com/theophoric/near-core-contracts-as/tree/master/contracts/voting

必看的3个合约:

  • SputnikDAO
    这个合约是一个简单的DAO版本,用来分发小费、奖金和奖励。允许任何人发送一个提议,用资金奖励其他人,并得到理事会投票。这个和 Moloch DAO 设计的主要区别是这个合约将通过捐赠得到它的功能,并且理事会有平等的权利。

  • Multisig
    This contract provides a multisig scheme that allows making transfers, calling functions and adding / removing keys
    这个合约提供了一个multisig方案,允许进行传输、调用函数和添加/删除密钥

  • Whitelist
    The purpose of this contract is to maintain the whitelist of the staking pool contracts account IDs that are approved by NEAR Foundation.
    该合约的目的是维护由NEAR Foundation批准的权益池合约帐户ID的白名单。

SputnikDAO

https://github.com/VitalPointAI/SputnikDao-AS-Contract/tree/main/sputnikdao-as

github: https://github.com/VitalPointAI/SputnikDao-AS-Contract/tree/main/sputnikdao-as

SputnikDAO 帮助你在 NEAR 创建链上基金,并参与去中心化自治组织。

A smart contract written in AssemblyScript for an app initialized with create-near-app.
用AssemblyScript编写的针对使用create-near-app初始化的应用程序的智能合约。

多签合约(Multisig-Contract)

https://github.com/VitalPointAI/Multisig-Contract
相关参考: https://vitalpoint.ai/course/multisig-contract/

多重签名合约的整个前提是它可以实现要求多个人或实体在执行请求之前确认请求/提议的逻辑。这称为从N个多重签名方案中设置K个,其中N是参与者的总数,K是在执行请求或提议之前必须达成一致的数目。

此多重签名合约允许已添加到其中的密钥的所有者请求签名传输,函数调用或添加/删除现有或其他密钥。

没有时间限制。任何授权的访问密钥都可以进行确认,直至达到所需的确认数量。

让我们看一下整个过程的概述:

步骤1:初始化

  • 确定在执行某些请求操作之前我们需要多少确认;和
  • 我们要用来初始化的所有帐户的公钥(应该大于我们想要的确认数)。

例如,我要部署一个包含三个参与者(三个访问密钥)的多重签名,并且在执行任何操作之前,我想要两个单独的确认。换句话说,使用合同的三个人中的两个必须同意请求。

有了这些信息,我们可以部署调用它的initContract函数的合约。

当然,一个人可以分配任意数量的密钥,并增加或减少所需的确认数。一个人也可以稍后添加更多密钥或更改所需的确认数。

步骤2:FunctionCall存取键

NEAR具有两种访问键-fullAccess和functionCall访问。初始化时,我们设置了三个functionCall访问键,并赋予它们对methodNames数组标识的方法(“ add_request”,“ delete_request”和“ confirm”)的访问权限。因为它们是functionCall访问键-它们只能调用合约上的这三个更改功能(以及任何视图功能)。在上面的示例中,这三个键代表使用合约的三个人-A,B,C。

步骤3:提交请求

在星号3-用户C向合约提交多重签名请求。我们假设这是将资金转给某人的请求。附近。使用Near-CLI会采用以下形式:

转账要求

near call multisig.vitalpoint.ai add_request '{"request": {"receiver_id": "somebody.near", "actions": [{"type": "Transfer"}],  "amount": "1000000000000000000000" }}' --accountId multisig.vitalpointai.testnet

向Multisig添加另一个密钥

near call multisig.vitalpoint.ai add_request '{"request": {"receiver_id": "multisig.vitalpointai.testnet", "actions": [{"type": "AddKey"}],  "public_key": "<base58 of the key>"}}' --accountId multisig.vitalpointai.testnet

更改批准多重签名请求所需的确认数

near call multisig.vitalpoint.ai add_request '{"request": {"receiver_id": "multisig.vitalpointai.testnet", "actions": [{"type": "SetNumConfirmations"}],  "num_confirmations": 2}}' --accountId multisig.vitalpointai.testnet

所有这些都返回request_id,可用于查询/确认详细信息。还请记住,您可以创建将多个操作链接在一起的更复杂的调用。

请注意,合约“ add_request_and_confirm”中有一种方法与“ add_request”具有相同的功能,但是它通过添加请求的键将请求提交与确认结合在一起。如果使用“ add_request”提交,则用户(在这种情况下为C)仍然需要确认。不要忘记在初始化时将’add_request_and_confirm’添加到methodNames数组中,以提供适当的权限来调用它到访问键。

合约也有许多视图请求,您可以调用这些视图请求以获取一些信息:
列出所有请求ID

near view multisig.vitalpointai.testnet list_request_ids

查看有关特定请求的信息

near view multisig.vitalpointai.testnet list_request_ids

查看特定请求的确认

near view multisig.vitalpointai.testnet get_request '{"request_id: 0"}'

任何request 所需的确认总数

near view multisig.vitalpointai.testnet get_confirmations '{"request_id: 0"}'

步骤4:确认
在星标4处-用户的B和C都在合约上调用“确认”方法,以表明他们对关联的request_id的支持。非常简单。看起来像这样:

near call multisig.vitalpointai.testnet confirm '{"request_id": 0}' --accountId multisig.vitalpointai.testnet

当我们初始化需要2/3确认的合约时-用B&C的确认,它会触发execute_request函数,该函数将我们带到最后一步。

步骤5:执行
执行正是听起来的样子。由于在步骤3提交的请求收到了必要的两次确认,因此execute_request函数将执行并执行属于请求的任何动作(假定所有相关参数都存在)。他们包括:

  • 转移
  • 创建帐号
  • 部署帐户
  • AddKey
  • 删除键
  • 函数调用
  • SetNumConfirmations

MultiSig合约有什么好处呢?

发挥您的想象力-可能会想到许多情况,在这种情况下,提交请求并在参与人员中达成多数(或其他共识)是有意义的。

从本质上讲,这就是去中心化自治组织(DAO)的运行方式,在这种情况下,NEAR的帐户和访问密钥系统以及multisig合约为实现这些系统开辟了一些新颖的方式。

这种多重信号可能是超级健壮的DAO的开始。可以将合约扩展为包括其他各种请求类型,并且DAO的成员(如其访问键所示)可以指示对某些请求的支持,添加/删除其他成员或您能想到的任何其他内容。

它是可升级的
但如果您决定这样做,请务必小心-以下请求将在给定帐户上部署新的合同代码。您需要考虑数据并需要迁移(合同更新应包括向前迁移的数据)。


const fs = require('fs');
const account = await near.account("vitalpointai.testnet");
const contractName = "multisig.vitalpointai.testnet";
const requestArgs = {"request": [{"receiver_id": "multisig.illia", "actions": [{"type": "DeployContract", "code":       fs.readFileSync("out/multisig.wasm")}]}
]};
const result = account.signAndSendTransaction(contractName,[nearAPI.transactions.functionCall("add_request", Buffer.from(JSON.stringify(requestArgs)),10000000000000, "0"),
]);

这仍然像是一个请求,并且需要通过合约的确认数量来进行确认。

Whitelist

https://github.com/VitalPointAI/Whitelist-Contract

The purpose of this contract is to maintain the whitelist of the staking pool contracts account IDs that are approved by NEAR Foundation.

该合约的目的是维护由NEAR Foundation批准的权益池合约帐户ID的白名单。

Counter

https://github.com/near-examples/counter

该合约实现了由存储在区块链上支持的简单计数器。

NEAR开发者认证 NCD - Day1相关推荐

  1. NEAR开发者认证 NCD - Day3

    文章目录 Day3课程 测试 web3 资源 AssemblyScript Rust Day3课程 https://learnnear.club/lessons/day-3-testing-web3- ...

  2. Node.js基金会官方的开发者认证准备就绪

    Node.js基金会正在为新的Node.js开发者认证(Developer Certification)做最后的准备工作,该认证计划于十二月推出. \\ 新推出的认证可能将采用一种不同于开发人员习以为 ...

  3. Jchatting通过Sina SAE云开发平台高级开发者认证

    2019独角兽企业重金招聘Python工程师标准>>> 前几天刚收到中级开发者的证书,并且在上一篇博文Sina SAE云计算平台中级开发者证书中刚刚秀了秀证书~~~通过提交开源项目J ...

  4. 谷歌官方TensorFlow开发者认证来了,吴恩达:学我的课,报名费五折

    郭一璞 发自 凹非寺 量子位 报道 | 公众号 QbitAI 只要100刀--700块,TensorFlow官方开发者认证,就可以到手了. 而且AI大牛吴恩达也权威背书认可. 但前提是,得通过考试. ...

  5. tensorflow手册_谷歌TensorFlow开发者认证考试来了!哪些要点需要了解?

    全文共878字,预计学习时长4分钟 图源:devclass.com 3月12日,TensorFlow框架的开发团队谷歌大脑发布了第一个TensorFlow开发者认证项目,全世界的TensorFlow开 ...

  6. QQ互联开发者认证一直审核未通过的原因

    QQ互联开发者认证一直审核未通过 地址:https://connect.qq.com 注意事项, 上传一张手持身份证照片, 记住,身份证头像出现在右侧!!!

  7. 微信开放平台开发者认证

    1.邮箱注册,激活账号 2.企业认证 3.登陆微信开放平台,进行开发者认证 4.填写认证信息 5.发票选择,可以选择不开发票 6. 支付费用300 备注:如有疑问,请联系作者!

  8. Java手机游戏开发简明教程 (SunJava开发者认证程序员 郎锐)

    原文发布时间为:2008-07-30 -- 来源于本人的百度文章 [由搬家工具导入] Java手机游戏开发实例简明教程 (SunJava开发者认证程序员 郎锐) 一.手机游戏编写基础 1.手机游戏设计 ...

  9. 华为开发者认证与DevEco Studio编译器下载

    文章目录 认证华为开发者 下载并安装Node.js与DevEco Studio 尝试打开DevEco Studio    认证华为开发者   认证华为开发者的目的有 3 个:一是可以在其官方网站上下载 ...

最新文章

  1. 通用软件测试的6个角度
  2. 学JS的心路历程 -数组常见处理方法
  3. Java 代码完成删除文件、文件夹操作
  4. Spring Cloud Feign 使用Apache的HTTP Client替换Feign原生httpclient
  5. eai app_EAI的Spring集成教程
  6. oracle多表查询while,oracle while的用法示例分享
  7. linux c一站式编程 答案,linuxc一站式编程答案.docx
  8. 第k小的数(二分、partition)
  9. Python 实现信息自动配对爬虫排版程序
  10. GDataDate 的本地时间转换
  11. log4net 不生成日志文件的解决办法
  12. nginx反代+varnish缓存+后端LAMP平台集群实现
  13. Jquery实现滚动到底部加载更多(最原始)
  14. 彻底解决Android GPS没法定位这一顽固问题
  15. 灵格斯词霸 2.6.3 - 小窗口, 大世界
  16. TCP的乱序和丢包判断(附Reordering更新算法)-实例case
  17. 深度神经网络的成功应用,深度神经网络技术赋能
  18. crc16 c语言 非查表,CRC16CCITT(1021)的16字表长查表程序
  19. 在AVD上运行程序时,程序闪退并报错unfortunately,xx has stopped
  20. egg extend ts_NAS初体验—威联通TS-451D - jingkunliu

热门文章

  1. GFOJ738:Cource--动态规划练习2 DFS+树形DP
  2. CFF 1016 计算天数
  3. MXNet 0.11发布,加入动态图接口Gluon,还有两位CMU教授的亲笔教程
  4. 餐饮行业如何打开市场
  5. arg min函数c语言,数学符号arg含义
  6. 2012-12-21世界末日是不会来了。
  7. k8s结合Serverless、Istio实现核心云原生架构
  8. 切比雪夫中值定理验证联合概率的收敛性质
  9. python前程无忧scrapy存mogondb案例+可视化显示
  10. 王者荣耀服务器信息共享,腾讯将在《王者荣耀》中启用“账号时长共享”新功能...