Proxy Factory Deployment

I would like to manually deploy a factory contract once and spawn proxies at a later point.

Right now I’m using SimpleProject to set up the proxy factory.

const project = new SimpleProject(‘MyContract’, { from: creatorAddress });
  
await project.setImplementation(MyContract_v0);

let factoryAddress =  project.implementations.MyContract.address

Now that I have the project (proxy factory) address I would like to store it and use it in a function to spawn a new proxy when called.

const SpawnProxy = () => {

const project = new SimpleProject(‘MyContract’, { from: creatorAddress });
await project.setImplementation(MyContract_v0, factoryAddress);

  const proxy = await project.createProxy(MyContract_v0, { 
    initArgs: 
    [
    90, 
    0, 
    10, 
    "0x54c85fb1627bfbc9171b38389614b067d42b2970", 
    "0x54c85fb1627bfbc9171b38389614b067d42b2970",
    ["0x75cf54f313fab4936b2766808d2fcbcb7213c351"]  
  ]})

return proxy._address
}

When trying this with my setup it doesn’t seem to be working. The setImplementation function creates a new proxy factory instead of using the one that has already been created.

How can I achieve the desired result?

Bonus: Proxies I’m creating have are ownable and it doesn’t seem to be set correctly when querying who the owner is. Ideally, it would be the person who created the factories.

1 Like

Hey @tor! Can you try using registerImplementation instead of setImplementation? Something like the following:

project.registerImplementation("MyContract", { address: factoryAddress })

By the way, I’m aware we need to do a better job at documenting the programmatic interface, and we’re working on it. In the meantime, please feel free to ask here any questions you may have!

2 Likes

That seemed to do the trick. Thank you.

2 Likes