defi/nft/lp/dapp/dao代币发行合约流动性质押挖矿分红系统开发详情版(通缩销毁,锁仓限购,买卖回流,回购拉盘模式开发)

简介: When the peer node receives the input (propsal) requested by the client, it will send a chain code message object (with input information and caller information) to the corresponding chain code.

Fabric chain code interacts with peer node through gprc

When the peer node receives the input (propsal) requested by the client, it will send a chain code message object (with input information and caller information) to the corresponding chain code.

The chain code calls the invoke method in ChaincodeBase to obtain the ledger status information and send the pre submission status to the peer node by sending the getState and putState messages.

The chain code sends the final output result to the peer node, and the node endorses and signs the input (propsal) and output (propsalreponse) to complete the first signature submission.

After that, the client collects the first segment of the submission information of all peer nodes, assembles the transaction and signs it, sends the transaction to the orderer node for queuing, and finally the orderer generates the block and sends it to each peer node, and puts the input and output on the ledger to complete the second segment of the submission process.

Basis of chain code development:

The foundation of chain code development can be summarized as follows: one base class, two queries, and one write.

A base class: ChaincodeBase

In Java, ChaincodeBase is the contract base class of user-defined chain codes. The run (ChaincodeStub stub, String function, String [] args) method is the entry function for peer to call chain codes. An init method must be customized for contract initialization and upgrade initialization.

Because of its dynamic interface characteristics, GO does not need to specifically declare the implementation of the contract interface. However, two interface methods must be implemented:

▪ Init (stub shim. ChaincodeStubInterface): init is used for contract initialization and upgrade initialization;

▪ Invoke (stub ship. ChaincodeStubInterface): Invoke is the entry function of peer calling chain code; ChaincodeStub contains rich ledger operations, such as getCallerCertificate(), getState (k), putState (k, v), invokeChaincode (...), rangeQueryState (k1, k2), getTxId(), etc.

Two queries: getState (k) and rangeQueryState (k1, k2)

GetState (k) gets the value corresponding to a separate key.

RangeQueryState (k1, k2) gets all k-v objects that start with k1 and end with k2, and returns Map<String, String>objects, where k1 and k2 are sorted lexicographically.

One write: putState (k, v),

Write the data. It should be noted here that putState data will not fall into the ledger immediately. The data will not fall into the ledger until the second transaction submission consensus is reached.

Chain code development experience

  1. Store the business entity in Json mode and create an index on the key

Because there is only one key val status database, the data whose value is Json can be quickly parsed. The key is added with the value of some simple index fields, such as Pk_ TxId Transaction ID_ A field value to realize range query.

The leveldb used by the k-v library of the fabric, and the lexicographical order used by the inserted key values. Therefore, the index field values must have a fixed length, or call stub. rangeQueryState (k1, k2) for range query, and a heap of incorrect data will be taken out.

  1. The written data cannot be obtained immediately

The data written through putState will not fall into the ledger immediately. The data will not fall into the ledger until the consensus of all peer nodes in the second transaction is reached. Therefore, it is not possible to immediately obtain the previously written values, such as batch inserting data, using putState to write data, and then using the getState function to determine whether the primary key is repeated.

  1. Do the methods in the chain code need to be locked

unwanted. The peer node has implemented the message queue. The chain code messages sent to the chain code are executed sequentially, not in parallel.

相关文章
|
6月前
|
供应链 安全 区块链
Dapp/defi代币通缩燃烧销毁模式流动性LP质押项目系统开发
要理解智能合约的概念和作用,首先需要了解区块链的基本架构
|
6月前
|
存储 区块链
NFT卡牌代币质押DAPP系统开发|详情原理
去中心化应用是指基于区块链技术的应用,可以实现去中心化的数据存储和验证
|
算法 区块链
Defi+NFT质押流动性挖矿系统开发/LP质押挖矿功能开发解析
Defi+NFT质押流动性挖矿系统开发/LP质押挖矿功能开发解析
|
区块链
defi/lp/nft/dapp代币预售合约流动性质押挖矿开发正式版,defi/lp/nft/dapp代币预售合约流动性质押挖矿系统开发(方案及详细)
 智能合约(Smart contract)是依托计算机在网络空间运行的合约,它以信息化方式传播、验证或执行合同,由计算机读取、执行,具备自助的特点。而区块链的去中心化,数据的防篡改,决定了智能合约更加适合于在区块链上来实现
|
JavaScript 前端开发 UED
LSD赛道流动性挖矿dapp系统开发源代码|LP流动性质押分红模式定制详情
LSD赛道流动性挖矿dapp系统开发源代码|LP流动性质押分红模式定制详情
dapp/defi/nft/lp借贷理财流动性质押挖矿开发功能版,dapp/defi/nft/lp借贷理财流动性质押挖矿系统开发(开发方案)
From the perspective of conceptual model,the metauniverse is the superposition of technology system,content system,economic system,cooperation system and governance system.The core of the technical system is integration,and its technical system should be characterized by open
|
区块链
代币合约dapp开发丨代币合约dapp流动性质押挖矿分红系统开发实现技术案例及源码
 因为整个区块链系统是点对点的对等网络,没有统一的中心机构协调各个节点的行为,所以在生成区块时,各个节点的行为都是相互独立的,很有可能同时由多个矿工在同一区块高度生成出2个以上的区块来。这些区块打包的交易很可能是不一样的,同时满足条件的数字n不是唯一的,多个矿工之间生成的数字n是不一样的,但是同样是满足不等式的。在这种情况下,网络中的其他节点很可能同步到不同的区块数据,并且这些数据在数学上都是合法的、有效的。当不同的节点中的不同的区块作为当前最新区块时,就会存在分叉的情况,即不同的矿机对同一高度的区块生产了内存不一样的新区快,并且这些矿工都找到了满足不等式的数字n。
|
区块链 数据库
defi/nft/lp/dapp/dao以太链/波场链/火币链/币安链发行合约代币流动性质押挖矿分红系统开发(稳定版)及代码部署
 智能合约与区块链的结合形成了智能合约法规自动执行系统,该系统有三个重要的原则:   首先,智能合约数据来源于链上。这是指智能合约的输入是从区块链的数据库里面出来的。这些数据是由区块链保证的,具有真实难以篡改的特征。
|
缓存 API 区块链
defi+nft+lp+dapp+dao智能合约流动性质押挖矿分红开发源码,defi+nft+lp+dapp+dao智能合约流动性质押挖矿分红系统开发详细及方案
  以最简单的方式来说,区块链记录着更新账本状态的交易,且记录不可篡改。智能合约以编程方式访问账本两个不同的部分:一个是区块链(记录所有交易的历史,且记录不可篡改),另一个是世界状态(保存这些状态当前值的缓存,是经常需要用到的对象的当前值)。
|
JSON 区块链 数据格式
DEFI/NFT/LP/DAPP代币合约流动性质押挖矿分红开发案例源码,DEFI/NFT/LP/DAPP代币合约流动性质押挖矿分红系统开发(逻辑及详细)
# web3对象与已部署的用户合约进行通信 rpc = "HTTP合约通讯地址(http url)" web3 = Web3(HTTPProvider(rpc))