Hello I am having problems passing accessing the structure Rental in my secound contract can some one help?

contract RentalCompleting{

struct Rental {
    uint256 stratingDate;
    uint256 endingDate;
    uint256 maxRentalDuration;
    uint256 drivingLicenseExpirationDay;
    uint256 depositAmount;
    string car;
    uint256 invoiceAmount;

Rental public rental;

constructor() public{
    initiator = 0xf1055613923229f387780bC5bC92CEB8DbCEFE07; //rentACar
    executor = msg.sender; //client
    rental.maxRentalDuration = 10000000;

DepositPaying public depositPaying;

function returnsRental(address _address) public view returns (Rental memory){
    return Rental(rental.stratingDate, 

function requestRentalCompleting(uint256 _startingDate, uint256 _endingDate, uint256 _drivingLicenseExpirationDay) public{
             require(_endingDate >= _startingDate);
             require((_endingDate - _startingDate) <= rental.maxRentalDuration);
             require(_drivingLicenseExpirationDay >= _endingDate);
             rental.stratingDate = _startingDate;
             rental.endingDate = _endingDate;
             rental.drivingLicenseExpirationDay = _drivingLicenseExpirationDay;                 
function promiseRentalCompleting() public
         returns (address){
             depositPaying = new DepositPaying(address(this));                 
             return address(depositPaying);

contract DepositPaying{

RentalCompleting public rentalCompleting;

constructor(address _rentalCompleting) public{
    rentalCompleting = RentalCompleting(_rentalCompleting);
    initiator = rentalCompleting.executor(); //client                            
    executor = rentalCompleting.initiator(); //rentACar

function getRental() view public returns (RentalCompleting.Rental memory){
    return rentalCompleting.returnsRental(address(this));

uint256 r = getRental().depositAmount;
function requestDepositPaying(uint256 _rq_depositAmount) public
             require(_rq_depositAmount == r);
             c_fact = C_facts.Requested;
  • You have undeclared variables in your smart contract, try fixing that first. For example what is c_fact ? – Miroslav Nedelchev Jul 27 '20 at 16:41

You are executing uint256 r = getRental().depositAmount outside a function, although it compiles it doesn't seems to do what you are expecting.

It seems you want to execute it inside requestDepositPaying function.

function requestDepositPaying(uint256 _rq_depositAmount) public {
    uint256 r = getRental().depositAmount;
    require(_rq_depositAmount == r);

If you want to read other members from the Rental struct you can assign to a variable.

RentalCompleting.Rental memory rental = getRental();

require(_rq_depositAmount == rental.depositAmount);

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