示例#1
0
        public async void ShouldBeAbleToEncodeTheSameAsTheSmartContract()
        {
            var web3              = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Rinkeby);
            var signer            = new Eip712TypedDataSigner();
            var gnosisSafeAddress = "0xa9C09412C1d93DAc6eE9254A51E97454588D3B88";
            var chainId           = (int)Chain.Rinkeby;
            var service           = new GnosisSafeService(web3, gnosisSafeAddress);
            var param             = new EncodeTransactionDataFunction
            {
                To             = "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D",
                Value          = 0,
                Data           = "0x40A2aCCbd92BCA938b02010E17A5b8929b49130D".HexToByteArray(),
                Operation      = (byte)ContractOperationType.Call,
                SafeTxGas      = 0,
                BaseGas        = 0,
                GasPrice       = 0,
                GasToken       = AddressUtil.AddressEmptyAsHex,
                RefundReceiver = AddressUtil.AddressEmptyAsHex,
                Nonce          = 1
            };
            var encoded = await service.EncodeTransactionDataQueryAsync(param);

            var domain = new Domain
            {
                VerifyingContract = gnosisSafeAddress,
                ChainId           = chainId
            };

            var encodedMessage = signer.EncodeTypedData(param, domain, "SafeTx");

            Assert.Equal(encoded.ToHex(), encodedMessage.ToHex());
        }
示例#2
0
        public async void ShouldCheckBalanceOfMultipleAccounts()
        {
            //Connecting to Ethereum mainnet using Infura
            var web3 = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Mainnet);

            //Setting the owner https://etherscan.io/tokenholdings?a=0x8ee7d9235e01e6b42345120b5d270bdb763624c7
            var balanceOfMessage1 = new BalanceOfFunction()
            {
                Owner = "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643"
            };                                                                                                                          //compound
            var call1 = new MulticallInputOutput <BalanceOfFunction, BalanceOfOutputDTO>(balanceOfMessage1,
                                                                                         "0x6b175474e89094c44da98b954eedeac495271d0f"); //dai

            var balanceOfMessage2 = new BalanceOfFunction()
            {
                Owner = "0x6c6bc977e13df9b0de53b251522280bb72383700"
            };                                                                                                                          //uni
            var call2 = new MulticallInputOutput <BalanceOfFunction, BalanceOfOutputDTO>(balanceOfMessage1,
                                                                                         "0x6b175474e89094c44da98b954eedeac495271d0f"); //dai

            await web3.Eth.GetMultiQueryHandler().MultiCallAsync(call1, call2);

            Assert.True(call1.Output.Balance > 0);
            Assert.True(call2.Output.Balance > 0);
        }
示例#3
0
        public async void ShouldGetTheDaiFromMainnet()
        {
            var web3                 = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Mainnet);
            var contractHandler      = web3.Eth.GetContractHandler("0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359");
            var stringBytes32Decoder = new StringBytes32Decoder();
            var symbol               = await contractHandler.QueryRawAsync <SymbolFunction, StringBytes32Decoder, string>();

            var token = await contractHandler.QueryRawAsync <NameFunction, StringBytes32Decoder, string>();
        }
示例#4
0
        public async void ShouldGetTransactionByHash()
        {
            var web3     = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Mainnet);
            var txnType2 = await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync("0xe7bab1a12b9234a27a0f53f71d19bc0595f1ea2c8148f5d45edac76a4566e15b");

            var txnLegacy = await web3.Eth.Transactions.GetTransactionByHash.SendRequestAsync("0x8751032c189f44478b13ca77834b6af3567ec3e014069450f17209ed0fd1a3c1");

            Assert.True(txnType2.Type.ToTransactionType() == TransactionType.EIP1559);
            Assert.True(txnLegacy.Type.ToTransactionType() == TransactionType.Legacy);

            Assert.True(txnType2.Is1559());
            Assert.True(txnLegacy.IsLegacy());
        }
示例#5
0
        public async void ShouldBeAbleToRegisterExample()
        {
            var durationInDays = 365;
            var ourName        = "lllalalalal"; //enter owner name
            var tls            = "eth";
            var owner          = "0x111F530216fBB0377B4bDd4d303a465a1090d09d";
            var secret         = "Today is gonna be the day That theyre gonna throw it back to you"; //make your own


            var web3          = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Mainnet);
            var ethTLSService = web3.Eth.GetEnsEthTlsService();
            await ethTLSService.InitialiseAsync();

            var price = await ethTLSService.CalculateRentPriceInEtherAsync(ourName, durationInDays);

            Assert.True(price > 0);

            var commitment = await ethTLSService.CalculateCommitmentAsync(ourName, owner, secret);

            var commitTransactionReceipt = await ethTLSService.CommitRequestAndWaitForReceiptAsync(commitment);

            var txnHash = await ethTLSService.RegisterRequestAsync(ourName, owner, durationInDays, secret, price);
        }
        public async void ShouldBeAbleToCalculateHistoryMedium()
        {
            if (_ethereumClientIntegrationFixture.EthereumClient == EthereumClient.Geth)
            {
                var web3 = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Goerli);


                var feeStrategy = new MedianPriorityFeeHistorySuggestionStrategy(web3.Client);
                for (var x = 0; x < 10; x++)
                {
                    Thread.Sleep(500);
                    var fee = await feeStrategy.SuggestFeeAsync();
                }
            }
        }