Java,区块链,以太坊

2019-01-03 01:07发布

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

1条回答
戒情不戒烟
2楼-- · 2019-01-03 01:43

学习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);
}
}

}

查看更多
登录 后发表回答