Skip to main content
deleted 27 characters in body
Source Link

I have 2 diffrent NFT collection. They are both transparentUpgradableProxy smart contracts. I used to call another function like this before I upgraded them to transparentUpgradableProxy.

function mint(uint256 tokenId) public payable {
   IERC721 token = IERC721(mainContractAddress);
   uint256 ownedAmount = token.balanceOf(msg.sender);
   require((ownedAmount / requiredNftAmountFirstStage) - claimedAmountFirstStage[msg.sender] > 0, "You are not eligible for free NFT!");
   require(ownerOf(tokenId) == address(0), "NFT already claimed!");

   _safeMint(msg.sender, tokenId);
   claimedAmountFirstStage[msg.sender] += 1;
}

After I changed it to transparentUpgradableProxy, I tried to do it like this:

IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
uint256 ownedAmount = token.balanceOf(msg.sender);

Im guessing this is not how it works. How can I access to another upgradable smart contracts function?

Thanks!

edit1: TriedI cant use delegatecall because it says its unsafe. My both smart contract is upgradableProxy. I tried to do it like this with delegatecall and itwill call, which returns bool and not uint256bytes.

    IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
    (bool success, bytes memory result) = address(mainContractAddresstoken).delegatecallcall(abi.encodeWithSignature("balanceOf(address)", msg.sender));
    require(success);

Otherwise gives error: Type bool is not implicitly convertible to expected type uint256.

This one gives error:

    uint256 ownedAmount = address(mainContractAddress).delegatecall(abi.encodeWithSignature("balanceOftoUint256(address)", msg.sender)result);

Still not working :( My other question is, I need to call that function from proxy smart contract right?

I have 2 diffrent NFT collection. They are both transparentUpgradableProxy smart contracts. I used to call another function like this before I upgraded them to transparentUpgradableProxy.

function mint(uint256 tokenId) public payable {
   IERC721 token = IERC721(mainContractAddress);
   uint256 ownedAmount = token.balanceOf(msg.sender);
   require((ownedAmount / requiredNftAmountFirstStage) - claimedAmountFirstStage[msg.sender] > 0, "You are not eligible for free NFT!");
   require(ownerOf(tokenId) == address(0), "NFT already claimed!");

   _safeMint(msg.sender, tokenId);
   claimedAmountFirstStage[msg.sender] += 1;
}

After I changed it to transparentUpgradableProxy, I tried to do it like this:

IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
uint256 ownedAmount = token.balanceOf(msg.sender);

Im guessing this is not how it works. How can I access to another upgradable smart contracts function?

Thanks!

edit1: Tried to do it like this with delegatecall and it returns bool and not uint256

(bool success, ) = address(mainContractAddress).delegatecall(abi.encodeWithSignature("balanceOf(address)", msg.sender));
    require(success);

Otherwise gives error: Type bool is not implicitly convertible to expected type uint256.

This one gives error:

uint256 ownedAmount = address(mainContractAddress).delegatecall(abi.encodeWithSignature("balanceOf(address)", msg.sender));

I have 2 diffrent NFT collection. They are both transparentUpgradableProxy smart contracts. I used to call another function like this before I upgraded them to transparentUpgradableProxy.

function mint(uint256 tokenId) public payable {
   IERC721 token = IERC721(mainContractAddress);
   uint256 ownedAmount = token.balanceOf(msg.sender);
   require((ownedAmount / requiredNftAmountFirstStage) - claimedAmountFirstStage[msg.sender] > 0, "You are not eligible for free NFT!");
   require(ownerOf(tokenId) == address(0), "NFT already claimed!");

   _safeMint(msg.sender, tokenId);
   claimedAmountFirstStage[msg.sender] += 1;
}

After I changed it to transparentUpgradableProxy, I tried to do it like this:

IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
uint256 ownedAmount = token.balanceOf(msg.sender);

Im guessing this is not how it works. How can I access to another upgradable smart contracts function?

Thanks!

edit1: I cant use delegatecall because it says its unsafe. My both smart contract is upgradableProxy. I tried to do it will call, which returns bool and bytes.

    IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
    (bool success, bytes memory result) = address(token).call(abi.encodeWithSignature("balanceOf(address)", msg.sender));
    require(success);
    uint256 ownedAmount = toUint256(result);

Still not working :( My other question is, I need to call that function from proxy smart contract right?

added 339 characters in body
Source Link

I have 2 diffrent NFT collection. They are both transparentUpgradableProxy smart contracts. I used to call another function like this before I upgraded them to transparentUpgradableProxy.

function mint(uint256 tokenId) public payable {
   IERC721 token = IERC721(mainContractAddress);
   uint256 ownedAmount = token.balanceOf(msg.sender);
   require((ownedAmount / requiredNftAmountFirstStage) - claimedAmountFirstStage[msg.sender] > 0, "You are not eligible for free NFT!");
   require(ownerOf(tokenId) == address(0), "NFT already claimed!");

   _safeMint(msg.sender, tokenId);
   claimedAmountFirstStage[msg.sender] += 1;
}

After I changed it to transparentUpgradableProxy, I tried to do it like this:

IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
uint256 ownedAmount = token.balanceOf(msg.sender);

Im guessing this is not how it works. How can I access to another upgradable smart contracts function?

Thanks!

edit1: Tried to do it like this with delegatecall and it returns bool and not uint256

(bool success, ) = address(mainContractAddress).delegatecall(abi.encodeWithSignature("balanceOf(address)", msg.sender));
    require(success);

Otherwise gives error: Type bool is not implicitly convertible to expected type uint256.

This one gives error:

uint256 ownedAmount = address(mainContractAddress).delegatecall(abi.encodeWithSignature("balanceOf(address)", msg.sender));

I have 2 diffrent NFT collection. They are both transparentUpgradableProxy smart contracts. I used to call another function like this before I upgraded them to transparentUpgradableProxy.

function mint(uint256 tokenId) public payable {
   IERC721 token = IERC721(mainContractAddress);
   uint256 ownedAmount = token.balanceOf(msg.sender);
   require((ownedAmount / requiredNftAmountFirstStage) - claimedAmountFirstStage[msg.sender] > 0, "You are not eligible for free NFT!");
   require(ownerOf(tokenId) == address(0), "NFT already claimed!");

   _safeMint(msg.sender, tokenId);
   claimedAmountFirstStage[msg.sender] += 1;
}

After I changed it to transparentUpgradableProxy, I tried to do it like this:

IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
uint256 ownedAmount = token.balanceOf(msg.sender);

Im guessing this is not how it works. How can I access to another upgradable smart contracts function?

Thanks!

I have 2 diffrent NFT collection. They are both transparentUpgradableProxy smart contracts. I used to call another function like this before I upgraded them to transparentUpgradableProxy.

function mint(uint256 tokenId) public payable {
   IERC721 token = IERC721(mainContractAddress);
   uint256 ownedAmount = token.balanceOf(msg.sender);
   require((ownedAmount / requiredNftAmountFirstStage) - claimedAmountFirstStage[msg.sender] > 0, "You are not eligible for free NFT!");
   require(ownerOf(tokenId) == address(0), "NFT already claimed!");

   _safeMint(msg.sender, tokenId);
   claimedAmountFirstStage[msg.sender] += 1;
}

After I changed it to transparentUpgradableProxy, I tried to do it like this:

IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
uint256 ownedAmount = token.balanceOf(msg.sender);

Im guessing this is not how it works. How can I access to another upgradable smart contracts function?

Thanks!

edit1: Tried to do it like this with delegatecall and it returns bool and not uint256

(bool success, ) = address(mainContractAddress).delegatecall(abi.encodeWithSignature("balanceOf(address)", msg.sender));
    require(success);

Otherwise gives error: Type bool is not implicitly convertible to expected type uint256.

This one gives error:

uint256 ownedAmount = address(mainContractAddress).delegatecall(abi.encodeWithSignature("balanceOf(address)", msg.sender));
Source Link

Calling function from another upgradable proxy smart contract

I have 2 diffrent NFT collection. They are both transparentUpgradableProxy smart contracts. I used to call another function like this before I upgraded them to transparentUpgradableProxy.

function mint(uint256 tokenId) public payable {
   IERC721 token = IERC721(mainContractAddress);
   uint256 ownedAmount = token.balanceOf(msg.sender);
   require((ownedAmount / requiredNftAmountFirstStage) - claimedAmountFirstStage[msg.sender] > 0, "You are not eligible for free NFT!");
   require(ownerOf(tokenId) == address(0), "NFT already claimed!");

   _safeMint(msg.sender, tokenId);
   claimedAmountFirstStage[msg.sender] += 1;
}

After I changed it to transparentUpgradableProxy, I tried to do it like this:

IERC721Upgradeable token = IERC721Upgradeable(mainContractAddress);
uint256 ownedAmount = token.balanceOf(msg.sender);

Im guessing this is not how it works. How can I access to another upgradable smart contracts function?

Thanks!