コード例 #1
0
        public static async Task DeployLibrary()
        {
            // 1. Unclock Account
            var unlockTime = new HexBigInteger(120);

            WriteLog($"Unlock account for {unlockTime.Value}s\n" +
                     $"  address: {EV.WalletAddress}\n" +
                     $"  pass:    {EV.WalletPassword}\n\n");
            var unlockRes = await _web3.Personal.UnlockAccount.SendRequestAsync(
                EV.WalletAddress, EV.WalletPassword, unlockTime);

            // 2. Deploy library
            WriteLog("Create transaction to deploy library\n" +
                     $"  gas: {_gas.Value}\n" +
                     $"  . . . Getting hash . . .");
            var transactionHash =
                await UsersAndFilesService.DeployLibraryAsync(_web3, EV.WalletAddress, _gas);

            WriteLog($"  hash: {transactionHash}");

            // 3. Mine transaction
            WriteLog("\nMine transaction\n" +
                     "  . . . Getting receipt . . .");
            var receipt = await UsersAndFilesService.MineAndGetReceiptAsync(_web3, transactionHash);

            WriteLog($"  gas used: {receipt.GasUsed.Value}");

            EV.LibraryAddress = receipt.ContractAddress;
            WriteLog($"\n>>> Library Address: {receipt.ContractAddress}");
        }
コード例 #2
0
        public async Task T1_DeployLibrary()
        {
            // 1. Unclock Account
            var unlockRes = await _web3.Personal.UnlockAccount.SendRequestAsync(
                SenderAddress, Password, new HexBigInteger(120));

            Assert.True(unlockRes);

            // 2. Deploy library
            var transactionHash =
                await UsersAndFilesService.DeployLibraryAsync(_web3,
                                                              SenderAddress, Gas);

            var receipt = await UsersAndFilesService.MineAndGetReceiptAsync(_web3, transactionHash);

            LibraryAddress = receipt.ContractAddress;

            Assert.True(!string.IsNullOrEmpty(transactionHash));
            Assert.NotNull(receipt);
        }