How to create a function to set this value “uint256 public investorHardCap =250000000000000000;” of autoswap token even the contract is already deployed

Link of the contract:https://github.com/laronlineworld/autoswap/blob/main/autoswap.sol It is possible to set the value “uint256 public investorHardCap =250000000000000000;” the investor cap even if the smart contract is deployed in bscscan?

The general idea in programming is that you have getter and setters - https://www.w3schools.com/cpp/cpp_encapsulation.asp (forgive the w3schools link).

What you want is a setter for that variable. You should keep in mind that you should limit it to owner only, so you need to include a modifier “onlyOwner()” if you want, but if not you can remove it.

The code:

function setInvestorHardCap (uint256 newInvestorHardCap ) public onlyOwner() {
      investorHardCap = newInvestorHardCap;
}

Read about modifiers here https://jeancvllr.medium.com/solidity-tutorial-all-about-modifiers-a86cf81c14cb

1 Like

This actually works and I used it already in other functions. Thanks mate.

1 Like