1

Is it possible to create a react app with truffle framework using the Proxy Contract of OpenZeppelin for upgradable contract?

What I understood is that one should send a transaction at Proxy contract (configured with the latest version of the contract) sending as msg.data the method of the upgradable contract that I want to execute. But, how to bring this logic into Truffle-react framework for create a DApp built on upgradable contract?

1

Yes, that is possible and not much different from usual development.

What I understood is that one should send a transaction at Proxy contract (configured with the latest version of the contract) sending as msg.data the method of the upgradable contract that I want to execute.

No, that is not the case. You should call you contract as usual using web3, but swapping contract address with proxy address. Example:

const balance1 = await MyToken.at(impl_proxy.address).balanceOf(sender);

Aside that, it is as usual as typical truffle/react/web3/solidity project.

  • Thank you for your answer. So, I have to deploy proxy contract to have the address and then in the truffle project I have to create an instance of my main contract, by passing the address of proxy contract, right? Like import MainContract from '../build/contracts/Contract.json' ... const contract = require('truffle-contract'); const mainContract = contract(MainContract); ... return mainContract.at('proxyContractAddress').then((instance) => { ... } And then calling mainContract functions as usual? Thank you. – Bruce Wayne Oct 29 '18 at 10:15
  • Sorry for the bad graphics of the comment, but it's the best I was able to do! – Bruce Wayne Oct 29 '18 at 10:17
  • 2
    No, you have to deploy your main contract first. Then deploy proxy contract with your main contract address as parameter to its constructor. After that you can call methods of your main contract as mainContract.at('proxyContractAddress').then((instance) => { ... } – Igor Yalovoy Oct 29 '18 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.