solidity는 어떻게 블록체인에 데이터를 저장하고 추출합니까

1258 단어
pragma solidity ^0.4.0;
contract Rent {

    uint price1;
    address addr1;
    uint public roomIndex;
    mapping(address => mapping(uint => Room)) stores;
    mapping(uint => address) roomIdInStore;

    struct Room{//fangwu duixiang 
        uint  id;   //fanmgwu  ID
        string name;
        string ty; //zhengzu  hezu 
        string imageLink;//tupian  HASH
        string descr;   //fangwumiaoshu 
        uint price; //zujin 
        address ad;
    }

   function Rent() public {//gouzaohanshu 
       roomIndex = 0;
       addr1 = msg.sender;
   }
// 
function addRoomToStore(string name,string ty,string imageLink,string descr,uint price) public {
       roomIndex += 1 ;
       Room memory room = Room(roomIndex,name,ty,imageLink,descr,price,addr1) ;
       stores[msg.sender][roomIndex]=room;
       roomIdInStore[roomIndex] = msg.sender;
   }

// 
   function getRoom(uint id) view public returns(uint,string,string,string,string,uint,address){
       Room memory room = stores[roomIdInStore[id]][id];
       price1 == room.price;
       return(room.id,room.name,room.ty,room.imageLink,room.descr,room.price,addr1);
   }
는 단순 계약이다.여러분, IDE에 넣어서 테스트를 해보세요.

좋은 웹페이지 즐겨찾기