pragma solidity >=0.4.22 <0.6.0;
contract Person {

    //owner address
    address private owner;

    string private firstName;
    string private lastName;
    string private SID; 

    constructor(string memory _firstName, string memory _lastName, string memory _SID) public {
        owner = msg.sender;
        firstName = _firstName;
        lastName = _lastName;
        SID = _SID;

    modifier checkAccess(){
        require(this.getAccess() == true);

    function getAccess() public view returns(bool access){
        //here will be more validation, but for now I just added this one
        return msg.sender == owner;

    function getFirstName() public view checkAccess returns (string memory _firstName){
        _firstName = firstName;
    function getLastName() public view returns (string memory _lastName){
        _lastName = lastName;
    function getSID() public view returns (string memory _SID){
        _SID = SID;

So I have this smart contract and I try to use a function inside the modifier and it gives me this error:

call to Person.getFirstName errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value. Debug the transaction to get more information.

Any idea why and how can it be solved? I wanna to add more checkings into getAccess function, checking a list of addresses or something like that, but for now I only added owner == msg.sender

EDIT: Copy paste the code into https://remix.ethereum.org in order to see more clearly the error

  • You have one reason for a revert in your code, and that is the require statement, which verifies that the function is called with the same account used for deploying the contract. So the simple conclusion is that you've deployed the contract with one account and called the function with another account. Side note: you should post your off-chain code if you want this question to be answered properly, since this code is the reason for the error that you're describing. Commented Mar 2, 2019 at 8:40
  • Done, you can check it now into remix.ethereum.org Commented Mar 2, 2019 at 9:02

1 Answer 1


turn this

require(this.getAccess() == true);

into this:

require(getAccess() == true);

I haven't find out the detail why but when i debugged it on remix your code seem to loop forever and have infinite amount of gas so it revert.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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