Confusion with minimal proxy deployment contract missing

I am trying to deploy this contract

pragma solidity ^0.5.0;

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

contract Namer is Initializable {
 string private name;

 function initialize(string memory _name) public initializer {
    name = _name;
 }

 function setName(string memory _name) public {
    name = _name;
 }

 function getName(string memory _name) public pure returns (string memory) {
    return _name;
 }
}

As a minimal proxy from the following contract

pragma solidity ^0.5.0;

import "./Namer.sol";
import "../node_modules/@openzeppelin/upgrades/contracts/upgradeability/ProxyFactory.sol";

contract Generator is ProxyFactory {
 
address[] public clones;

function createNamer(string memory name, address target) public returns (address)
 {
    bytes memory _payload = abi.encodeWithSignature(
        "initialize(string)",
        name
    );
    address clone = deployMinimal(target, _payload);
    clones.push(clone);
    return clone;
 }

}

I followed the following sequence of commands to deploy the contracts

oz create Namer
oz create Generator

Then I call the createNamer on the Generator Function and a successful ProxyCreated event in emitted with the address of the new Proxy created.

When I call the address using the following command

oz call --to EmmitedAddress --method getName

I get the following error

Proxy at address EmmitedAddress not found.

I am not sure what I am doing wrong?

1 Like

Hi @morpherious,

Welcome to the community :wave:.

Please accept my apologies, I had missed replying to your post.

You should be able to import without "../node_modules".

I used OpenZeppelin CLI 2.8: Release Candidate as it supports regular (non-upgradeable) deploys. (prior to this the CLI only created upgradeable contracts)

npm i @openzeppelin/cli@rc

Deploy

Deploy the Generator as a regular contract

$ npx oz deploy
✓ Compiled contracts with solc 0.5.16 (commit.9c3226ce)
? Choose the kind of deployment regular
? Pick a network development
? Pick a contract to deploy Generator
✓ Deployed instance of Generator
0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab

Deploy the Namer as a regular contract

$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network development
? Pick a contract to deploy Namer
✓ Deployed instance of Namer
0x5b1869D9A4C187F2EAa108f3062412ecf0526b24

Create a Namer from the Generator

Use the address of the Namer

$ npx oz send-tx
? Pick a network development
? Pick an instance Generator at 0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab
? Select which function createNamer(name: string, target: address)
? name: string: hello
? target: address: 0x5b1869D9A4C187F2EAa108f3062412ecf0526b24
✓ Transaction successful. Transaction hash: 0x6479de090e4b82c2355961d884738f60c11eb0b23fefac8a9375df33512791ad
Events emitted:
 - ProxyCreated(0xcC5f0a600fD9dC5Dd8964581607E5CC0d22C5A78)

Interact with the Namer

OpenZeppelin CLI currently only supports interacting with contracts that have been deployed by it.

I will have to see if there is an easy way to interact with a contract.

Unfortunately we currently only support interacting with contracts created through oz create or oz deploy. There is a feature request for importing other contracts to be used with the CLI. Feel free to share your use case and show your support in the issue.

1 Like