简体   繁体   中英

Deploying Contracts with Circular Dependency in Truffle

The CryptoKitties contracts apparently have circular dependency. I don't know how to sequence the deployment of the contracts in Truffle.

ClockAuction's constructor requires an address to a contract that implements "ERC721".

In this code, ERC721 is implemented by KittyOwnership, which inherits from KittyBase.

KittyBase contains reference to SaleClockAuction, which inherits from ClockAuction.

How should the Truffle deployment be structured here?

KittyBase can't be deployed without SaleClockAuction being deployed first. However, SaleClockAuction's parent's constructor needs an address for KittyOwnership, which inherits from KittyBase.

In a nutshell:

  • ClockAuction needs the address of deployed KittyOwnership.
  • KittyOwnership inherits from KittyBase.
  • KittyBase needs SaleClockAuction.
  • SaleClockAuction inherits from ClockAuction.

As far as I can see, it's really important to determine what part of the contracts lead to setters/getters, and what contracts are combined together.

They might have circular dependency, but they all lead to a setter functions like setSiringAuctionAddress and setSaleAuctionAddress

You'd probably have more luck following the breadcrumbs of the actual live contracts themselves:

Core: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code

Siring: https://etherscan.io/address/0xc7af99fe5513eb6710e6d5f44f9989da40f27f26#code

Sale: https://etherscan.io/address/0xb1690c08e213a35ed9bab7b318de14420fb57d8c#code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM