I want to design a system, which the user system is not releate to the house model, but if the user want to find house, he/she must sign in. So how to establish their contacts (my house model byte is approaching the upper limit, it cannt directly import the user model)?

put on hold as too broad by shane, Richard Horrocks, alberto, Achala Dissanayake, Niklas Feurstein Sep 10 at 8:45

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


Let me give you a few suggestions since it sounds like the real problem you have here is that your contract is nearly at the gas limit.

  1. You can wait and see vitalik and hope that vitalik manages to boost the gas limit.
  2. Try to find optimizations in your contract, or use external calls (to see if a person is a user) which cuts less gas.
  3. Assuming that you are using infura whitelisting certain ip addresses should prevent anyway from using your contract from outside your site and then you make sure they log in with metamask and basic logic to reject spammy users.
  4. If you could post your smart contract, perhaps people could tell you know how to reduce the smart contract size.
  5. Another approach which I would recommend investigating is gas station network which allows users to interact with smart contracts without logging in, so essentially it is a different way of handling logins. Maybe using gas station network would involve using some sort of manual verification process (need to validate income documents or something similar).
    1. Also consider using an oracle to check if the user exists.

The reason I made a post is because there is a comment limit.

But please you will need to give more information.

  • Yes, the second will reduce a lot of gas by step2. I use external calls by interface, but it cannt return the value of calling the contract method.And I post some part of my contrct, can you reduce the smart contract size? the code is the above. @GrandFleet – Smith Jone Sep 8 at 8:45
  • Now I cannt get whether the user sign in or not by using external calls. – Smith Jone Sep 8 at 9:00

Yes, the second will reduce a lot of gas by step2. I use external calls by interface, but it cannt return the value of calling the contract method.And I post some part of my contrct, can you reduce the smart contract size?

interface RegisterInterface {
  function isLogin(address _userAddr) external;

contract RentBasic {
   enum HouseState {
HouseState defaultState = HouseState.ReleaseRent;
struct HouseInfo {          
        uint8    landRate; 
        uint8    ratingIndex;  
        uint8    huxing;     
        string   houseAddress;      
        bytes32  houseId;   
        string   descibe;   
        string   landlordInfo;              
        string   hopeYou;       
        address  landlord;      
struct HouseReleaseInfo {
    HouseState    state;  
    uint32        tenancy;
    uint256       rent; 
    uint          releaseTime;  
    uint          updateTime; 
    uint          dealineTime;  
    bool          existed; 
// RentToken token;
ERC20Interface token;
TenancyAgreement tenancyContract;
RegisterInterface userRegister;
HouseInfo public hsInformation;
mapping(bytes32 => HouseInfo) houseInfos; 
mapping(bytes32 => HouseReleaseInfo) hsReleaseInfos; 
mapping(address => uint) public addrMoney; 
mapping(bytes32 => RemarkHouse) public remarks; 
mapping(bytes32 => RemarkTenant) public remarkTenants; 
mapping(bytes32 => mapping(address => uint)) bonds; 
mapping(address => address) l2rMaps;
mapping(address => uint256) creditManager; 
mapping(address => uint256) lockAmount;

address public owner; 

address public receiverPromiseMoney = 0x3c13520Bc27C8A38FD67533d02071e775da7b12F; 
address public distributeRemarkAddr = 0xA4ef5514CCfe79B821a3F36A123e528e096cEa28; 
address public saveTenanantAddr = 0xF87932Ee0e167f8B54209ca943af4Fad93B3B8A0; 
address public punishAddr = 0x960bEDf8DF0A6e66B470ba560eE6fD1e0e32Ee23; 

uint256 promiseAmount = 500 * (10 ** 8);
uint256 punishLevel1Amount = 10 * (10 ** 8); 
uint256 remarkAmount = 4 * (10 ** 8);

event ReleaseInfo(bytes32 houseHash, HouseState _defaultState, uint32 _tenancy, uint256 _rent, uint _releaseTime, uint _deadTime, bool existed);    
event ReleaseBasic(bytes32 houseHash, uint8 rating,string _houseAddr,uint8 _huxing,string _describe, string _info, string _hopeYou,address indexed _landlord);      
event SignContract(address indexed _sender, bytes32 _houseId, uint256 _signHowLong, uint256 _rental, bytes32 _signatrue, uint256 _time);
event CommentHouse(address indexed _commenter, uint8 _rating, string _ramark);
event RequestSign(address indexed _sender, bytes32 _houseId,uint256 _realRent, address indexed saveTenanantAddr);
event BreakContract(bytes32 _houseId, address indexed sender,string _reason,uint8 _punishLevel,uint256 uptime);
event WithdrawDeposit(bytes32 _houseId,address indexed sender,uint256 amount,uint256 nowTime);
// event RenterRaiseCrowding(address indexed _receiver, uint256 _fundingGoal, uint256 _durationInMinutes, address indexed _tokenContractAddress);

constructor(address _token, address _register) {
    owner = msg.sender;
    token = ERC20Interface(_token);
    userRegister = RegisterInterface(_register);

modifier gtMinMoney(uint amount) {
    require(amount >= promiseAmount, "promise amount is not enough");

modifier onlyOwner() {
    require(msg.sender == owner);

modifier onlyLogin() {
    bool flag = userRegister.isLogin(msg.sender);
    if (!flag) {
function releaseHouse(string _houseAddr,uint8 _huxing,string _describe, string _info, uint32 _tenancy, uint256 _rent, string _hopeYou) public onlyLogin returns (bytes32) {
    uint256 nowTimes = now; 
    uint256 deadTime = nowTimes + 7 days;
    address houseOwer = msg.sender;
    // releaser should hold not less than 500 BLT
    token.transferFrom(houseOwer, receiverPromiseMoney, promiseAmount);
    addrMoney[houseOwer] = promiseAmount;
    bytes32 houseIds = keccak256(abi.encodePacked(houseOwer, nowTimes, deadTime));
    hsInformation = HouseInfo({             
        landRate: 2,         
        ratingIndex: 2,
        huxing: _huxing,            
        hopeYou: _hopeYou,
        houseAddress: _houseAddr,           
        houseId: houseIds, 
        descibe: _describe,
        landlordInfo: _info,
        landlord: houseOwer         
    houseInfos[houseIds] = hsInformation;
    hsReleaseInfos[houseIds] = HouseReleaseInfo({
        state: defaultState,
        tenancy: _tenancy,
        rent: _rent,
        releaseTime: nowTimes,
        updateTime: nowTimes,
        dealineTime: deadTime,
        existed: true
    // releations[houseId].leaser = houseOwer;
    ReleaseBasic(houseIds, 2, _houseAddr, _huxing, _describe, _info, _hopeYou, houseOwer);
    ReleaseInfo(houseIds, defaultState, _tenancy,_rent,nowTimes,deadTime,true);
    return houseIds;
function deadReleaseHouse(bytes32 _houseId) returns(bool) {
    HouseReleaseInfo hsRelInfo = hsReleaseInfos[_houseId];
    if (now > hsRelInfo.dealineTime && hsRelInfo.state == HouseState.Renting) {
        hsReleaseInfos[_houseId].state = HouseState.Cance;
        return true;
    return false;
function requestSign(bytes32 _houseId, uint256 _realRent) public onlyLogin returns (HouseState,address){
    HouseInfo hsInfo = houseInfos[_houseId];
    HouseReleaseInfo hsReInfo = hsReleaseInfos[_houseId];
    address sender = msg.sender;
    require(hsReInfo.existed, "House is not existed");
    require(hsReInfo.state == defaultState, "House State is not in release");
    token.transferFrom(sender, saveTenanantAddr, _realRent);
    hsReleaseInfos[_houseId].state = HouseState.WaitRent;
    bonds[_houseId][msg.sender] = _realRent;
    // releations[_houseId].tenant = msg.sender;
    l2rMaps[hsInfo.landlord] = sender;
    RequestSign(sender, _houseId, _realRent, saveTenanantAddr);
    return (hsReInfo.state, hsInfo.landlord);


  • Alternatively consider using ipfs to store house description and address, while only having the hash in the smart contract. Would also make sense if you wanted to store images as well itnext.io/… You could fiddle around with types, particular timestamps to try to save space. ethereum.stackexchange.com/questions/28969/… on only login you could remove the variable and check if(userRegister.isLogin) – GrandFleet Sep 8 at 16:22
  • It need a address for userRegister.isLogin. If I directly use userRegister.isLogin, the address cannt pass to isLogin method. – Smith Jone Sep 10 at 14:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.