Using Beacon proxy pattern with API

Hey guys,

I’m currently looking for solution for smart contract upgrades and came across the beacon pattern. I found some good tutorials here in the forum about deploying upgradable porxies with truffle but still those solutions don’t fit my requirements, or at least I don’t see it. So here is my setup and my understanding so far:
I have an api were I can have an endpoint for POST contract/. This endpoint will then trigger a deployment of a new smart contract. I will deploy quite a lot of smart contracts to a private PoA network.
Now I want to integrate the upgradable feature for the smart contract and so far I came across the proxy pattern where each proxy contract delegates the calls to the implementation contract. The thing is if I have a few hundred smart contracts, upgrading all of them requires to iterate over each of one of them. That’s why I found the beacon approach very interesting.
In the plugins for hardhat an truffle exist a function like deployProxy but so far they are only used in the migrations of truffle.

  1. My questions would be if there is a way to deploy new proxies from an route handler and thus outside of the truffle migrations?
  2. I found the beacon proxy in the docs but how do I use it with truffle?

Thanks a lot and all the best


Hi @kiliw,

Welcome to the community :wave:

Given your use case on wanting a large number of upgradeable contracts for the one implementation, then BeaconProxy sounds like a possible solution.

You should be able to deploy from contracts using web3.js or ethers.js.

For an example on using the BeaconProxy you can look at the tests:

Hey thank you very much for your fast answer. That pointed me directly to what I was looking for :grinning: Don’t get it why I didn’t find it myself though. Anyway thanks again.

All the best :wave:

1 Like

Ideally you would be able to use truffle exec but there are some issues with Truffle that cause the upgrades plugins to not work with truffle exec.

You would be able to use Hardhat’s hardhat run to run a script using the upgrades plugin.

Regarding support for beacon proxies in the plugins: they aren’t supported yet, I’ll let you know once they are updated but we don’t have a timeline for it right now.

1 Like

A post was split to a new topic: Understanding BeaconProxy.test.js