如何将数据保存到区块链以及如何查询



我目前正在使用区块链为我的最后一年项目开发在线出生证明登记系统。我已经在我的项目中加入了Moralis来处理用户,并将其链接到Ganache。我在问是否有人能告诉我如何将html表单中的信息保存到区块链中。我在网上查过了,但似乎没有人知道我想要的确切答案。下面是HTML表单以及智能合约:当我点击";添加细节";,我希望收集到的所有信息都保存到区块链中。

  1. 我想找出相应的JavaScript代码
  2. 我想知道你可以用来查询区块链的智能合约和Javascript代码,这样它就可以显示这些信息,例如可以打印成出生证明

contract Obdrs {
uint256 dateOfBirth; //save date as unix timestamp or use a string
string gender;
string fullName;
string placeOfBirth;
string motherFullname;
string motherNrc;
string fatherFullname;
string fatherNrc;
string bo; //birthOccurence
string permanentAddress;
string contactNumber;
//... with all of your properties
function storeBirthCertificate(uint256 _dateOfBirth, string calldata _gender, string calldata _fullName, 
string calldata _placeOfBirth, string calldata _motherFullname, string calldata _motherNrc, string calldata _fatherFullname,
string calldata _fatherNrc, string calldata _bo, string calldata _permanentAddress, string calldata _contactNumber) public {
dateOfBirth = _dateOfBirth;
gender = _gender;
fullName = _fullName;
placeOfBirth = _placeOfBirth;
motherFullname = _motherFullname;
motherNrc = _motherNrc;
fatherFullname = _fatherFullname;
fatherNrc = _fatherNrc;
b0 = _bo;
permanentAddress = _permanentAddress;
contactNumber = _contactNumber;
}
}```

这是一个更简单的问题,需要用一系列数字进行检查

你需要创建一个映射,检索数据会更简单,但考虑到通配符搜索,那么数据将是一个复杂的信息,需要考虑数组推送的列表,

这是我对存储的理解

名称[]

出生日期[]

全名[]

性别[]

推送每一行中所有值的详细信息,最后一个索引位置应映射到主用户映射[referenceid]=recordid(数组的索引值(

这个参考id将在证书副本中共享,并进行通配符搜索,这将是一个更好的搜索算法,因为数据很大,有完整的记录集,其属性类型(如出生日期(可以是数字,名称可以是其他格式,

然后考虑以类似的方式查询多个数据,

但是保持一个not这不是一个常规的数据库,可以根据您想要的样式进行查询。

最新更新