Cannot set a proxy implementation to a non-contract address

I have deployed contracts;

FiatTokenV1

deployed with implementation address=0x612a2a33e4d34eb00d59f82a37918d88d8e332ec

FiatTokenProxy

In this transaction,
0x9b69cd36c3c4ed60a870647c36c9f7ea14a058ff7efa00c40cef3e196e7b4cbe
it says “Cannot set a proxy implementation to a non-contract address”

I am trying interact with web3.py library,

from web3 import Web3
w1 = Web3(Web3.HTTPProvider("https://ropsten.infura.io/v3/1111111111111111"))
FiatTokenV1abi = '[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_account","type":"address"}],"name":"unBlacklist","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"minter","type":"address"}],"name":"removeMinter","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_currency","type":"string"},{"name":"_decimals","type":"uint8"},{"name":"_masterMinter","type":"address"},{"name":"_pauser","type":"address"},{"name":"_blacklister","type":"address"},{"name":"_owner","type":"address"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"masterMinter","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"minter","type":"address"},{"name":"minterAllowedAmount","type":"uint256"}],"name":"configureMinter","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newPauser","type":"address"}],"name":"updatePauser","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"account","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"minter","type":"address"}],"name":"minterAllowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pauser","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newMasterMinter","type":"address"}],"name":"updateMasterMinter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"account","type":"address"}],"name":"isMinter","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newBlacklister","type":"address"}],"name":"updateBlacklister","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"blacklister","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currency","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_account","type":"address"}],"name":"blacklist","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_account","type":"address"}],"name":"isBlacklisted","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"minter","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"burner","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"minter","type":"address"},{"indexed":false,"name":"minterAllowedAmount","type":"uint256"}],"name":"MinterConfigured","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"oldMinter","type":"address"}],"name":"MinterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"newMasterMinter","type":"address"}],"name":"MasterMinterChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_account","type":"address"}],"name":"Blacklisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_account","type":"address"}],"name":"UnBlacklisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"newBlacklister","type":"address"}],"name":"BlacklisterChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"newAddress","type":"address"}],"name":"PauserChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"previousOwner","type":"address"},{"indexed":false,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]'
token = w1.eth.contract(Web3.toChecksumAddress("0x1F44a0ba0105d1f1D7670A5745974A6EE0C829A9"),abi= FiatTokenV1abi)
token.caller.balanceOf(Web3.toChecksumAddress("0xf7ecC98a786d27943e6204748f716284338D39b5"))

0
but expected balance is:

1 Like

Hey @Saim_Neftci! Thanks for reaching out here in the forum.

That transaction is the one that created the Proxy contract. If you check it out on Etherscan, you’ll see that it succeeded. The proxy was successfully created, and if you check out its implementation slot you’ll see that it correctly points to the FiatTokenV1.

> web3.eth.getStorageAt('0x1F44a0ba0105d1f1D7670A5745974A6EE0C829A9', '0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3')
'0x000000000000000000000000612a2a33e4d34eb00d59f82a37918d88d8e332ec'

I’m guessing you saw the Cannot set a proxy implementation to a non-contract address string in the transaction data itself. Don’t worry: the string is a revert reason that is part of the contract, so it was sent in the transaction data along with the rest of the contract itself. The tx was successful, and the proxy was created ok.

Can you share where you got that expected balance from?

Since I’m seeing at least one token transaction on the implementation contract itself, is it possible that you have been interacting directly with the FiatTokenV1 implementation contract when transferring or minting tokens?

1 Like

Dear spalladino, Thanks you for reply,
In this transaction minted,
https://ropsten.etherscan.io/tx/0x186067019f187410b17ba97d01b5f4618041ca14080be6cf8ddd904104974d77
I am used remix and minted from FiatTokenV1, Because I am used remix’s “Load contract from address” FiatTokenProxy contract functions there isn’t mint function.

1 Like

@Saim_Neftci if you have set up a Proxy contract and an Implementation contract, you always need to interact with the Proxy contract, since it’s the one that will keep its state. This means you will need to:

  1. Load the contract source (or at least the ERC20 interface) in Remix
  2. Compile it
  3. Choose to interact with a contract with the IERC20 interface at the proxy address (0x1f44…)

Let me know if this works!

1 Like

@spalladino


I did it but can’t use transfer function.

Please note, I initialized token from FiatTokenV1 contract address. Not initialized from FiatTokenProxy.
Token owner returning 0x000… address. I think I did a mistake when deploying contract from FiatTokenV1 contract address.

1 Like

Good catch! You need to initialize the proxy, not the implementation itself. Good news is that, if you never initialized the proxy, it may still be possible to initialize it with the initial allowances. If not, you can always deploy a new proxy to the same implementation contract. If you run oz create, it will reuse the existing implementation and deploy a new proxy.

1 Like

@spalladino I cant call initialization script.
With remix;
Compiled FiatTokenV1 loaded (“At address” button) new FiatTokenProxy address.
still same.
Note: The initialization function in FiatTokenV1

1 Like

Hi @Saim_Neftci,

Sorry, I am a little confused on how your contract was deployed.

If you haven’t already I suggest deploying your token contract using the OpenZeppelin CLI.

I deployed the following simple token using the CLI to Ropsten.

SimpleToken.sol

// contracts/SimpleToken.sol
pragma solidity ^0.5.0;

import "@openzeppelin/upgrades/contracts/Initializable.sol";

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol";

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the sender.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */
contract SimpleToken is Initializable, ERC20, ERC20Detailed {

    /**
     * @dev initialize that gives msg.sender all of existing tokens.
     */
    function initialize(address sender) public initializer {
        ERC20Detailed.initialize("Token", "TKN", 18);
        _mint(sender, 1000000 * (10 ** uint256(decimals())));
    }
}

I used the following instructions to deploy:
https://docs.openzeppelin.com/learn/connecting-to-public-test-networks

$ npx oz create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate SimpleToken
? Pick a network ropsten
✓ Contract SimpleToken deployed
All contracts have been deployed
? Call a function to initialize the instance after creating it? Yes
? Select which function * initialize(sender: address)
? sender (address): 0x77737a65C296012C67F8c7f656d1Df81827c9541
✓ Setting everything up to create contract instances
✓ Instance created at 0x128857b4356530cfA8B0B4f7049913736b8dA5Aa
0x128857b4356530cfA8B0B4f7049913736b8dA5Aa

This deployed to the following addresses on Ropsten:
Proxy: 0x128857b4356530cfA8B0B4f7049913736b8dA5Aa
Logic: 0x5fEd0bfbB09Ff0a57ceaB9Bd98870f87683636A7

I can interact with the contract using the following instructions: https://docs.openzeppelin.com/learn/deploying-and-interacting#interacting-from-the-command-line

$ npx oz call
? Pick a network ropsten
? Pick an instance SimpleToken at 0x128857b4356530cfA8B0B4f7049913736b8dA5Aa
? Select which function name()
✓ Method 'name()' returned: Token
Token

I also verified the logic contract

$ npx oz verify
? Pick a contract SimpleToken
? Pick a network ropsten
? Was the optimizer enabled when you compiled your contracts? No
? Select an endpoint etherscan
? Provide an etherscan API KEY **MY_API_KEY**
✓ Contract source code of SimpleToken verified and published successfully. You can check it here: https://ropsten.etherscan.io/address/0x5fEd0bfbB09Ff0a57ceaB9Bd98870f87683636A7#code

I can then use Etherscan to view and interact with the contract:
https://ropsten.etherscan.io/address/0x128857b4356530cfa8b0b4f7049913736b8da5aa#readProxyContract

Hi @Saim_Neftci,

Just checking how you got on with this?