智能合约 solidity-mapping.sol
pragma solidity ^0.8.3;contract Mapping{mapping(address =>uint)pubic myMap;function get(address _addr)pubic view returns(uint){return myMap[_addr];}function set(address _addr,uint _i)pubic{myMap[_a
·
pragma solidity ^0.8.3;
contract Mapping{
mapping(address =>uint)pubic myMap;
function get(address _addr)pubic view returns(uint){
return myMap[_addr];
}
function set(address _addr,uint _i)pubic{
myMap[_addr]=-i;
}
function remove(address _addr)pubic{
delete myMap[_addr];
}
}
contract NestedMapping{
mapping(address =>mapping(uint =>bool))pubic nested;
function get()address )addr1,uint _i}public view returns(bool){
return nested[_adddr1][_i];
}
function set(
address _addr1,
uint _i,
bool _boo
)public{
nested[_addr1][_i]=_boo;
}
function remove(address _addr1,uint _i)public{
delete nestedp[addr1][i];
}
}
更多推荐
已为社区贡献3条内容
所有评论(0)