Calling a Logic Contract through a proxy

I have my Logic contract, MyLogic.sol, with which I am using to make a call to another logic contract, ALogic.sol but I am doing so through a proxy contract, AProxy, and all contract versions are v0.5.5.

Here is a function on MyLogic.sol which is trying to call ALogic.sol through the proxy:

function run(address nftContractAddr, uint256 NFTId, uint256 priceInERC20Token) public returns (bool) {
  AProxyAddress.call(abi.encode("executefunction(address, uint256, uint256)", nftContractAddr, NFTId, priceInERC20Token));
}

Lets say executefunction is a public function on ALogic.sol which allows users to buy NFTs. I want the MyLogic.sol to buy the NFT by calling this function, and this NFT is then owned by MyLogic.sol contract address.

Any thought on how I am calling the ALogic contract wrongly?

1 Like

Hello @Etienereum, do you have any error or output to share?

Btw I believe the right way to encode the executefunction signature is without spaces between params: executefunction(address,uint256,uint256).

3 Likes

Hi @martriay,

I dont have any error. I am doing local testing so my test script is getting the balance of the addresses. The NFT I created does not move to the buyer which is the MyLogic.sol contract. I works perfectly fine if I directly call ALogic.sol, without going through AProxy.sol contract.

You are right on this,

executefunction(address,uint256,uint256),

but it has not still worked yet.

1 Like

Hi @Etienereum,

You could have a look Box.proxy.test.js in:
OpenZeppelin Upgrades: Step by Step Tutorial for Truffle