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: 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 - (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

1 Like

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

1 Like