コード例 #1
0
        /// <summary>
        /// Creates PlasmaComm object.
        /// </summary>
        /// <param name="ethClient">Ethereum jsonRpc client implementation</param>
        /// <param name="gameCenterContract">game center contract address</param>
        /// <param name="watcherClient">watcher client</param>
        /// <param name="childChainClient">child chain client</param>
        /// <param name="rootChainAddress">root chain address</param>
        /// <param name="_rootChainVersion">root chain version</param>
        public PlasmaComm(Nethereum.JsonRpc.Client.IClient ethClient,
                          string gameCenterContract,
                          PlasmaCore.RPC.IClient watcherClient,
                          PlasmaCore.RPC.IClient childChainClient,
                          string rootChainAddress,
                          RootChainVersion _rootChainVersion)
        {
            web3   = new Web3(ethClient);
            bcComm = new BCComm(ethClient, gameCenterContract);

            plasmaApiService = new PlasmaAPIService(watcherClient, childChainClient);
            rootChainVersion = _rootChainVersion;

            if (rootChainAddress == null)
            {
                var statusData = plasmaApiService.GetStatus().Result;
                rootChainAddress = statusData.ContractAddr;
            }

            if (rootChainAddress != null)
            {
                rootChainContract = new RootChainContract(web3, rootChainAddress, rootChainVersion);
            }

            transactionEncoder = TransactionEncoderFactory.Create(rootChainVersion, rootChainAddress);
        }
コード例 #2
0
        public Matic(MaticInitOptions options)
        {
            if (String.IsNullOrEmpty(options.MaticProvider))
            {
                throw new Exception("Matic Provider is required");
            }
            if (String.IsNullOrEmpty(options.ParentProvider))
            {
                throw new Exception("Parent provider is required");
            }

            //Assign the Web3 Provider Urls
            ParentProvider = options.ParentProvider;
            MaticProvider  = options.MaticProvider;

            //Define the Addresses For Matic
            RootChainContractAddress       = options.RootChainAddress;
            WithdrawManagerContractAddress = options.WithdrawManagerAddress;
            DepositManagerContractAddress  = options.DepositManagerAddress;

            //Define the Web3 Instances
            web3       = new Web3(MaticProvider);
            ParentWeb3 = new Web3(ParentProvider);

            //Create Root Chain Contract
            maticRootChainContract = new RootChainContract(ParentProvider, RootChainContractAddress);

            //Create Withdrawal Manger Contract
            maticWithrawalManagerContract = new WithdrawalManagerContract(MaticProvider, WithdrawManagerContractAddress);

            //Create Deposit Manager Contract
            maticDepositManagerContract = new DepositManagerContract(web3, DepositManagerContractAddress);

            //Assign the Syncer and Watcher Url
            SyncerUrl  = options.SyncerUrl;
            WatcherUrl = options.WatcherUrl;
        }