Skip to main content
deleted 1 character in body
Source Link
Jatago
  • 226
  • 1
  • 7

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):

pragma solidity ^0.4.25;

contract UserRegistration {
    function getUserData(address userAddress) public constant returns(string, uint) {
        string memory Firstname = "Hello";
        uint number=123;
        return( Firstname,number);
    }
}

contract SecondContract {
    function FetchDetail(address userAddress) public constant returns(string,uint ) {
        string memory  data1;
        uint  data2;
        UserRegistration ud=new UserRegistration();
        (data1,data2)= ud.getUserData(userAddress);
        return(data1,data2);
    }
}

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:

uint256 123

[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,!

Javier/Javi

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):

pragma solidity ^0.4.25;

contract UserRegistration {
    function getUserData(address userAddress) public constant returns(string, uint) {
        string memory Firstname = "Hello";
        uint number=123;
        return( Firstname,number);
    }
}

contract SecondContract {
    function FetchDetail(address userAddress) public constant returns(string,uint ) {
        string memory  data1;
        uint  data2;
        UserRegistration ud=new UserRegistration();
        (data1,data2)= ud.getUserData(userAddress);
        return(data1,data2);
    }
}

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:

uint256 123

[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,

Javier

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):

pragma solidity ^0.4.25;

contract UserRegistration {
    function getUserData(address userAddress) public constant returns(string, uint) {
        string memory Firstname = "Hello";
        uint number=123;
        return( Firstname,number);
    }
}

contract SecondContract {
    function FetchDetail(address userAddress) public constant returns(string,uint ) {
        string memory  data1;
        uint  data2;
        UserRegistration ud=new UserRegistration();
        (data1,data2)= ud.getUserData(userAddress);
        return(data1,data2);
    }
}

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:

uint256 123

[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super!

/Javi

deleted 16 characters in body
Source Link
Jatago
  • 226
  • 1
  • 7

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):


    pragma solidity ^0.4.25;
    
    contract UserRegistration {
        function getUserData(address userAddress) public constant returns(string, uint) {
            string memory Firstname = "Hello";
            uint number=123;
            return( Firstname,number);
        }
    }
    
    contract SecondContract {
        function FetchDetail(address userAddress) public constant returns(string,uint ) {
            string memory  data1;
            uint  data2;
            UserRegistration ud=new UserRegistration();
            (data1,data2)= ud.getUserData(userAddress);
            return(data1,data2);
        }
    }
 

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:


string Hello

uint256 123


uint256 123

[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,

Javier

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):


    pragma solidity ^0.4.25;
    
    contract UserRegistration {
        function getUserData(address userAddress) public constant returns(string, uint) {
            string memory Firstname = "Hello";
            uint number=123;
            return( Firstname,number);
        }
    }
    
    contract SecondContract {
        function FetchDetail(address userAddress) public constant returns(string,uint ) {
            string memory  data1;
            uint  data2;
            UserRegistration ud=new UserRegistration();
            (data1,data2)= ud.getUserData(userAddress);
            return(data1,data2);
        }
    }
 

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:


string Hello

uint256 123


[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,

Javier

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):

pragma solidity ^0.4.25;

contract UserRegistration {
    function getUserData(address userAddress) public constant returns(string, uint) {
        string memory Firstname = "Hello";
        uint number=123;
        return( Firstname,number);
    }
}

contract SecondContract {
    function FetchDetail(address userAddress) public constant returns(string,uint ) {
        string memory  data1;
        uint  data2;
        UserRegistration ud=new UserRegistration();
        (data1,data2)= ud.getUserData(userAddress);
        return(data1,data2);
    }
}

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:

uint256 123

[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,

Javier

added 22 characters in body
Source Link
Jatago
  • 226
  • 1
  • 7

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):


    pragma solidity ^0.4.25;
    
    contract UserRegistration {
        function getUserData(address userAddress) public constant returns(string, uint) {
            string memory Firstname = "Hello";
            uint number=123;
            return( Firstname,number);
        }
    }
    
    contract SecondContract {
        function FetchDetail(address userAddress) public constant returns(string,uint ) {
            string memory  data1;
            uint  data2;
            UserRegistration ud=new UserRegistration();
            (data1,data2)= ud.getUserData(userAddress);
            return(data1,data2);
        }
    } 

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:

 
string Hello 

uint256 123 


[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,

Javier

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):

pragma solidity ^0.4.25;

contract UserRegistration {
    function getUserData(address userAddress) public constant returns(string, uint) {
        string memory Firstname = "Hello";
        uint number=123;
        return( Firstname,number);
    }
}

contract SecondContract {
    function FetchDetail(address userAddress) public constant returns(string,uint ) {
        string memory  data1;
        uint  data2;
        UserRegistration ud=new UserRegistration();
        (data1,data2)= ud.getUserData(userAddress);
        return(data1,data2);
    }
}

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:

string Hello
uint256 123

[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,

Javier

Since Firstname is a string literal defined in the function scope, missing to explicitly define the data location sets it to storage by default (where the state variables are persisted) [1]. That assignment operation then looks for the data at the provided location, which in the example is not a valid storage reference. In order to solve the compilation error in the provided example, it is necessary to set the memory keyword, as pointed out by user smarx: string memory Firstname = "Hello";.

The second snippet is valid, as of Solidity version 0.4.25.

Given the provided code snippets, the following would be the aggregated code, to serve as reference (SecondContract.sol):


    pragma solidity ^0.4.25;
    
    contract UserRegistration {
        function getUserData(address userAddress) public constant returns(string, uint) {
            string memory Firstname = "Hello";
            uint number=123;
            return( Firstname,number);
        }
    }
    
    contract SecondContract {
        function FetchDetail(address userAddress) public constant returns(string,uint ) {
            string memory  data1;
            uint  data2;
            UserRegistration ud=new UserRegistration();
            (data1,data2)= ud.getUserData(userAddress);
            return(data1,data2);
        }
    } 

Deploying SecondContract and calling FetchDetail function with 0x0000000000000000000000000000000000000000 as argument returns:

 
string Hello 

uint256 123 


[1] https://solidity.readthedocs.io/en/v0.4.25/types.html#data-location

Stay super,

Javier

added 70 characters in body
Source Link
Rob Hitchens
  • 55.6k
  • 11
  • 91
  • 146
Loading
Source Link
Jatago
  • 226
  • 1
  • 7
Loading