1. ContractRegistry:
维护合约名字和合约地址的对应关系,这样其他合约通过合约名字访问时,可以得到最新的合约地址
mapping (bytes32 => RegistryItem) private items; // name -> RegistryItem mapping
string[] public contractNames; // list of all registered contract names

2.ContractIds:
定义了维护在ContractRegistry的合约的名字

3.BNT项目
ContractRegistry:https://etherscan.io/address/0x7148b1c9154bcf273a2c7d7b90e3edc6fee395e6
3.1.注册ContractFeatures到ContractRegistry
在别的合约需要访问ContractFeatures时可以通过以下方式访问:
IContractFeatures features = IContractFeatures(registry.addressOf(ContractIds.CONTRACT_FEATURES));
https://etherscan.io/tx/0x3038ae4bb59e841f153fe8c0dce617dfbba149c3c90576416f089152044de859

3.2. 注册BancorNetwork到ContractRegistry
在别的合约需要访问BancorNetwork时可以通过以下方式访问:
IBancorNetwork bancorNetwork = IBancorNetwork(registry.addressOf(ContractIds.BANCOR_NETWORK));
https://etherscan.io/tx/0x74ea2dd002c30d028c74b6d45bc83af0fe267afb552ad694b23b90d7a7f2648a

3.3. 注册BancorFormula到ContractRegistry
在别的合约需要访问BancorFormula时,可以通过以下方式访问:
IBancorFormula formula = IBancorFormula(registry.addressOf(ContractIds.BANCOR_FORMULA));
https://etherscan.io/tx/0x2af09023e2184b42fcfa8cd6263fb704b0781c886af354e4ef880880c1c36001

网友评论