thirdweb-dev / js

Best in class web3 SDKs for Browser, Node and Mobile apps
https://thirdweb.com
Apache License 2.0
430 stars 328 forks source link

Not operator or deployer error when deploy NFT drops contract on Ethereum & Polygon Mainnet #2458

Closed iggyiccy closed 5 months ago

iggyiccy commented 6 months ago

My team and I have been maintaining a fork of the Go SDK. But lately we are getting the error "not operator or deployer" when deploying NFT drops contract on the Ethereum and Polygon mainnet. The same code works on Polygon Mumbai testnet and can create NFT drops contract without any error.

https://github.com/qnfnypen/thirdweb-go-sdk/blob/4c2f3df09ac938b395b6488f3ef7112cb2010922/thirdweb/contract_deployer.go#L95

func (deployer *ContractDeployer) DeployNFTCollection(ctx context.Context, metadata *DeployNFTCollectionMetadata) (string, error) {
    metadata.fillDefaults()
    return deployer.deployContract(ctx, "nft-collection", metadata)
}

The error seems to be coming from the condition checks from the Registry contracts on whether the sender of the message (_msgSender()) has the OPERATOR_ROLE or if the sender is the _deployer. We had checked many times to confirm the sender is the deployer. Still, it works on Mumbai testnet but not on Ethereum and Polygon mainnet.

Does anyone has a clue?

joaquim-verges commented 6 months ago

@iggyiccy glad to hear you're maintaining a fork of the go sdk, although we have been depriotizing it in favor of our preferred backend solution: https://github.com/thirdweb-dev/engine

it can do everything that the go sdk could do and much more, and everything is exposed via a simple rest API, which is much easier to consume from any backend language.

That said, for your specific issue, we have deprecated the old TWFactory contracts in favor of a stateless, deterministic factory that is deployable by anyone on any chain.

The address is 0x76F948E5F13B9A84A81E5681df8682BBf524805E - has the same main API for deploying minimal clones, so you should be able to just replace the address in your fork i believe.

qnfnypen commented 6 months ago

@joaquim-verges glad to receive your reply, We tried using this address before(0x76F948E5F13B9A84A81E5681df8682BBf524805E), but found that even the test chain could not be successfully deployed after replacement. We referred to the TypeScript SDK in the official documentation and found that it was using the factory contract address WechatIMG10114

iggyiccy commented 6 months ago

@iggyiccy glad to hear you're maintaining a fork of the go sdk, although we have been depriotizing it in favor of our preferred backend solution: https://github.com/thirdweb-dev/engine

it can do everything that the go sdk could do and much more, and everything is exposed via a simple rest API, which is much easier to consume from any backend language.

That said, for your specific issue, we have deprecated the old TWFactory contracts in favor of a stateless, deterministic factory that is deployable by anyone on any chain.

The address is 0x76F948E5F13B9A84A81E5681df8682BBf524805E - has the same main API for deploying minimal clones, so you should be able to just replace the address in your fork i believe.

Thank you for recommending Engine. We will check it out see how can we integrate it moving forward.

Meanwhile, we had tried to point the SDK to the TWCloneFactory address "0x76F948E5F13B9A84A81E5681df8682BBf524805E" but it still doesn't work in resolving the authorisation issue we are getting. What's the different between the old factory and the new clone factory?

joaquim-verges commented 6 months ago

@iggyiccy the difference is that TWFactory (old one) also adds the deployed contract to the TWRegistry (what used to power the deployed contract list in the thirdweb dashboard and other places)

We ended up revoking all permissions on the TWRegistry as we moved to a new multichain approach (TWMultichainRegistry)

if you use the new TWStatelessFactory however, that only deploys the proxy and does not do anything else, and does not require any particular permission. Here's the signature of the deploy function: https://github.com/thirdweb-dev/contracts/blob/main/contracts/infra/TWStatelessFactory.sol#L28 which should match the old one

stale[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.