人工智能(Artificial Intelligence,简称AI)是指计算机系统在完成类似人类智力所需的任务时所表现出来的能力。它是一种复杂的技术,通过将大量的数据输入到算法中进行学习,不断调整和改进自己的算法,从而不断优化其性能。
代码分析
import
import"./RoleController.sol";
功能概述
创建或者修改DID的相关属性并用Event进行记录,可大体分为两类:创建或修改自身的属性以及有权限的机构创造或修改ID属性
整体结构
参数设置:关于区块链项目技术开发唯:MrsFu123,代币发行、dapp智能合约开发、链游开发、多链钱包开发
交易所开发、量化合约开发、互助游戏开发、Nft数字藏品开发、众筹互助开发、元宇宙开发、swap开发、
链上合约开发、ido开发、商城开发等,开发过各种各样的系统模式,更有多种模式、制度、案例、后台等,成熟技术团队,欢迎实体参考。
//使用import中的RoleController类
RoleController private roleController;
//changed[identity]:存储该id最近一次发生改变的区块
mapping(address=>uint)changed;
//记录合约建立时的区块
uint firstBlockNum;
//最新交易的区块
uint lastBlockNum;
//计数器:记录DID的总数
uint weIdCount=0;
//blockAfterLink[BlockNum]:与该区块相关联的下一个区块数
mapping(uint=>uint)blockAfterLink;
bytes32 constant private WEID_KEY_CREATED="created";
bytes32 constant private WEID_KEY_AUTHENTICATION="/weId/auth";
修改器(详细说明见上):
modifier onlyOwner(address identity,address actor){
require(actor==identity);
_;
}
1
2
3
4
构造器:
//需要roleControllerAddress的合约地址
function WeIdContract(
address roleControllerAddress
)
public
{
//将RoleController按照指定地址构造,这样方便后续RoleController合约更新升级
roleController=RoleController(roleControllerAddress);
//初始化firstBlockNum与lastBlockNum
firstBlockNum=block.number;
lastBlockNum=firstBlockNum;
}
构造Event事件:
event WeIdAttributeChanged(
address indexed identity,
bytes32 key,
bytes value,
uint previousBlock,
int updated
);
event WeIdHistoryEvent(
address indexed identity,
uint previousBlock,
int created
);