TypeError: Immutable variables can only be initialized inline or assigned directly in the constructor.
uniswapV2Pair = IUniswapV2Factory(_newPancakeRouter.factory()).createPair(address(this), _newPancakeRouter.WETH());
So it can not actually be changed by a function? Trying to find a solution which would work when pancake swaps to new version.
Hi, putting your solution to constructor () public leads to ParserError: Expected '(' but got identifier function setRouterAddress(address newRouter) public onlyOwner() { ^--------------^
Can’t actually get it right, would be glad to hear some help, thanks
Of course it is not supposed to be in a constructor. It is a separate function. But I am not a proper solidity dev (yet) and do not understand why it can not set a variable right now, going to google a little bit.
Thank you, removing Immutable seems to be doing the trick. Can you please clarify what “immutable” means? Like, not changeable by function or something? Thanks in advance.
Hi FreezyEx, Great post thanks, can you describe where in the contract is the best place to put this function or can we put it anywhere in the sol file? Newbie, learning by doing stuff!
I'm getting a checksum error in remix for v2 router, I'm assuming I can ignore this as have checked the address on BCScan site. Wont let me compile the contract actually 0x10ed43c718714eb63d5aa57b78b54704e256024e
Hi FreezyEx, the contract looks good and compiles to BSC live, however when I try to activate the function to change the router I get this strange error.
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Internal JSON-RPC error. { “code”: 3, “message”: “execution reverted: Pancake: PAIR_EXISTS”, “data”: "0x08c379a0000000…
I tried in remix giving the the testnet address, also tried the V2 address so the same as the hardcoded version. Also tried on bsc write contract page.
ok that seems to work, however now realised its not possible to change it back to the V2 setting as its giving me the same error. I guess this is supposed to only change to a new setting once not back and forth.