bval-contracts – bval合同区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,bval-contracts – bval合同区块链毕设代写 是一篇很好的国外资料

bval-contracts

Solidity smart contracts for the BVAL-NFT project.

Development

Install all deps

$ npm i 

Start local blockchain

$ npm run blockchain:local 

Run truffle tests

$ npm test 

Compile and build all contracts

$ npm run build 

Overview

This repo has an ERC-721 and an ERC-20 contract that are designed to work together:

ERC-721

Implementation Base

Based on a modified version of the latest ERC-721 implementation from OpenZeppelin (to cut gas a bit):

  • Removes dynamic length string storage
  • Removes metadata extension
  • Removes hook function

Token ID encoding

The 256 bits of the ERC-721 tokenID are used to encode information about the token. This allows for immutable, intrinsic information about a token to be represented on-chain in an ERC-721 compat way.

  • Token number, sequence number, collection version
  • Mint date and created date
  • $BVAL emission rate and state change cost
  • Edition number / edition total
  • Information about the asset (resolution, type)
  • etc…

Sequences

See Sequenced.sol

  • A sequence is a series of tokens
  • Each token belongs to a single sequence
  • A token’s sequence is encoded into its ID (see token ID encoding)
  • A sequence can be “completed”, preventing any further tokens from being minted in that sequence
  • A sequence cannot be re-started once completed
  • Multiple sequences may be started in parallel
  • A sequence may be registered with an “engine”, which will be called during token state changes
Sequence Engines

Sequence engines allow for additional on-chain behaviors and mechanics to be added after the initial contract deploys.

  • A sequence engine implements a single method that is called during token state change
  • The sequence engine can validate the state change or cause additional side effects
  • The engine may override the value that is actually written to token state

On-chain Metadata via Events

On-chain events are emitted to announce collection/sequence/token metadata in a durable way:

  • In the constructor, a CollectionMetadata event is published
  • Whenever a sequence is started, a SequenceMetadata event is published
  • Whenever a token is minted, a TokenMetadata event is published
  • Whenever a sequence is completed, a SequenceComplete event is published

Token State

  • Each token has a uint256 state value associated with it
  • Only the token holder can set this state
  • State can be set to any arbitrary value if no sequence engine is specified
  • State changes may be modified or constrained by a sequence engine
  • State is designed to be used to build on and off chain experiences in the future
  • Changing state may require $BVAL
  • State change cost is an intrinsic property of a token (encoded into its ID)

Marketplace Interop

  • Implements Rarible’s royalty interface
  • Implements OpenSea’s collectionURI interface
  • Implements EIP-2981 royalty spec

ERC-20

Implementation Base

Based on a modified version of the latest ERC-20 implementation from OpenZeppelin (to cut gas a bit):

  • Removes dynamic length string storages for symbol/name
  • Removes hook function

Collection Registration

  • A mapping can be set by the contract owner from a token version to a contract address
  • This mapping can only be set once
  • This is used to resolve the above ERC-721 contract from the collection version extracted from a NFT token ID

Claiming $BVAL

  • The holder of a BVAL-NFT can call the claim method with an array of token IDs
  • NFTs “emit” $BVAL at a rate determined by an emission rate encoded into their token IDs
  • Calling claim will mint new $BVAL corresponding to how much has been emitted since the last claim
  • Emission stops if deadman’s switch has been tripped (existing accumulated $BVAL can still be claimed)
  • NFTs minted in the first year of the contract start with a bonus of 1 month’s worth of accumulated $BVAL

Deadman Switch

  • The pingDeadmanSwitch method must be called once a year, or $BVAL emission will stop (claims still still occur for outstanding $BVAL)
  • Once the switch is tripped, there’s no way to reset it

bval合同

BVAL-NFT项目的Solidity智能合同。

开发

安装所有DEP

$ npm i 

启动本地区块链blockchain

$ npm run blockchain:local 

运行块菌测试

$ npm test 

编译并构建所有合约

$ npm run build 

概述

此回购拥有一个ERC-721和一个ERC-20合约,旨在协同工作:

ERC-721

实现基础

基于OpenZeppelin最新ERC-721实现的修改版本(减少一点气体):

  • 删除动态长度字符串存储
  • 删除元数据扩展
  • 删除钩子函数

令牌ID编码序列序列引擎通过事件链上元数据声明$BVAL

ERC-721tokenid的256位用于编码关于令牌的信息。这允许有关令牌的不可变的内在信息以ERC-721 compat方式在链上表示。

  • 令牌号、序列号、收集版本
  • 造币日期和创建日期
  • $BVAL排放率和状态更改成本
  • 版本号/版本总数
  • 有关资产的信息(解析,类型)
  • 等。。。序列是一系列令牌,每个令牌都属于一个序列,令牌的序列被编码到它的ID中(参见令牌ID编码),序列可以被“完成”,防止任何进一步的令牌在该序列中被铸造,一旦完成,序列就不能被重新启动

令牌状态

参见已排序.sol

  • 多个序列可以并行启动
  • 一个序列可以用“引擎”注册,将在令牌状态更改期间调用的序列引擎实现在令牌状态更改期间调用的单个方法序列引擎可以验证状态更改或引起附加的副作用构造函数中,每当序列启动时,发布CollectionMetadata事件;每当令牌被造币时,发布SequenceMetadata事件;每当序列完成时,发布TokenMetadata事件,发布SequenceComplete事件
  • 每个令牌都有一个与其关联的uint256状态值
  • 只有令牌持有者可以设置此状态
  • 如果未指定序列引擎,则可以将状态设置为任意值
  • 状态更改可以由序列引擎修改或约束设计用于在未来构建链上和链下体验
  • 更改状态可能需要$BVAL
市场互操作

序列引擎允许在初始合同部署后添加额外的链上行为和机制。

  • 状态更改成本是令牌的固有属性(编码到其ID中)
  • 实现Rarable的royalty接口
  • 实现OpenSea的collectionURI接口

ERC-20

发出链上事件,以持久的方式宣布集合/序列/令牌元数据:

  • 实现EIP-2981版税规范删除符号/名称的动态长度字符串存储
  • 删除钩子函数
  • 合同所有者可以设置从令牌版本到合同地址的映射
  • 此映射只能设置一次

实现库

  • 此映射用于从收集版本解析上述ERC-721合同从NFT令牌ID提取的BVAL-NFT的持有者可以调用具有令牌ID数组的声明方法,NFT以编码到其令牌ID中的发射速率确定的速率“发射”$BVAL调用声明将产生与自上一个声明以来发射的量相对应的新的$BVAL如果deadman开关跳闸,排放停止(仍然可以申请现有的累计$BVAL)
  • 合同第一年铸造的NFT开始时,每年必须调用一次PingDeadman开关方法,或者$BVAL排放将停止(仍有未付$BVAL的索赔)
  • 一旦开关跳闸,就无法重置它
  • State changes may be modified or constrained by a sequence engine
  • State is designed to be used to build on and off chain experiences in the future
  • Changing state may require $BVAL
  • State change cost is an intrinsic property of a token (encoded into its ID)

集合注册

  • Implements Rarible’s royalty interface
  • Implements OpenSea’s collectionURI interface
  • Implements EIP-2981 royalty spec

死机开关

Implementation Base

基于OpenZeppelin最新ERC-20实现的修改版本(减少一点气体):

  • Removes dynamic length string storages for symbol/name
  • Removes hook function

Collection Registration

  • A mapping can be set by the contract owner from a token version to a contract address
  • This mapping can only be set once
  • This is used to resolve the above ERC-721 contract from the collection version extracted from a NFT token ID

Claiming $BVAL

  • The holder of a BVAL-NFT can call the claim method with an array of token IDs
  • NFTs “emit” $BVAL at a rate determined by an emission rate encoded into their token IDs
  • Calling claim will mint new $BVAL corresponding to how much has been emitted since the last claim
  • Emission stops if deadman’s switch has been tripped (existing accumulated $BVAL can still be claimed)
  • NFTs minted in the first year of the contract start with a bonus of 1 month’s worth of accumulated $BVAL

Deadman Switch

  • The pingDeadmanSwitch method must be called once a year, or $BVAL emission will stop (claims still still occur for outstanding $BVAL)
  • Once the switch is tripped, there’s no way to reset it

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/20649.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » bval-contracts – bval合同区块链毕设代写

提供最优质的资源集合

立即查看 了解详情