Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 245
Jonas Arcangel Avatar asked Jan 01 '26 08:01

Jonas Arcangel


1 Answers

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

like image 56
ReyHaynes Avatar answered Jan 06 '26 15:01

ReyHaynes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!