Solidity

Solidity Tuple

Solidity kullanarak bir fonksiyondan birden fazla değişkeni döndürmek ve dönen değeri kullanmakla ilgili örnek paylaşacağım.

    function ArzYukselt(address to, uint256 amount) public onlyOwner {
        bool checkMint=false;
        (checkMint,,) = ArzEklenebilirMi(amount);
        require(checkMint, "adet cok yuksek");
        uint256 _calcAmount = amount * 10 ** decimals();
        _mint(to, _calcAmount);
    }

    function ArzEklenebilirMi(uint256 amount) public view returns(bool, uint256, uint256) {
        uint256 _calcAmount = amount * 10 ** decimals();
        uint256 _currentSupply = totalSupply();
        uint256 _maxSupply = 100000000 * 10 ** decimals();
        if(_currentSupply +_calcAmount <= _maxSupply) {
            return (true, _calcAmount, _currentSupply);
        }
        return (false, _calcAmount, _currentSupply);
    }