Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i check the value of my variable present in the smart contract? #45

Open
deepaklohmod6789 opened this issue Mar 18, 2022 · 1 comment

Comments

@deepaklohmod6789
Copy link

deepaklohmod6789 commented Mar 18, 2022

I wanna check the value of tokenCounter. Do I need to create a function which will return the value or I can access it directly with some predefined function present in the package?

contract AdvancedCollectible is ERC721 {
    uint256 public tokenCounter;

    constructor() public ERC721("Birds", "B") {
        tokenCounter = 0;
    }

    function createCollectible(string memory tokenUri)
        public
        returns (uint256)
    {
        uint256 newTokenId = tokenCounter;
        _safeMint(msg.sender, newTokenId);
        _setTokenURI(newTokenId, tokenUri);
        tokenCounter += 1;
        return tokenCounter;
    }
}
@4xMafole
Copy link

4xMafole commented Jan 17, 2023

Hello, @deepaklohmod6789.
As for solidity if you declare a variable public internally the language creates a get for it. Simply means you do not need an extra function to access the variable, just access it by name as you access the functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants