首页 新闻 会员 周边 捐助

Java,区块链,以太坊

0
悬赏园豆:30 [已解决问题] 解决于 2018-06-07 11:36

Java如何让自定义的数据,存储到以太坊的区块链上,公链,私链都可以!要方便后期查询,最好是key-value的方式!

tuwosh的主页 tuwosh | 初学一级 | 园豆:18
提问于:2018-05-25 15:14
< >
分享
最佳答案
0

学习solidity语言

 

 

pragma solidity ^0.4.10;
contract success{
address owner;
/* function Counter() view {
owner==msg.sender;
} */

struct target{
string name;
string age;
// int preindex;
}
/*struct tar{
address[] addr;
mapping(address=>target) preindex;
}*/
uint [] arr;
uint id;
mapping(uint => target) public map;
// mapping(uint=>uint) public indexMap;
target[] targets;
mapping(address=>target[]) public resMap;
// uint a=2;
uint index;
function tarInsert(uint a,string b,string c,address addr) public returns(uint) {
id=a;
map[id]=target({
name:b,
age:c
// preindex:(targets.length-2)
});
index = targets.push(map[id]);
resMap[addr]=targets;
return index;
}

function getTarget() public view returns(uint){
return id;
}
//销毁合约
function kill() public {
if (owner == msg.sender) {
selfdestruct(owner);
}
}

}

tuwosh | 初学一级 |园豆:18 | 2018-06-07 11:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册