Exemplo n.º 1
0
        public async Task StaticCallTest()
        {
            var request = new ContractStaticCallRequestDto
            {
                Address = "SXY3xT8FnCfNTTZF3si777QyXAdwALP3QSu",
                Payload = "06fdde03"
            };
            var res = await _httpService.ContractStaticCall(Network, request);

            var json = JsonSerializer.Serialize(res);

            _testOutputHelper.WriteLine(json);
        }
Exemplo n.º 2
0
        // #region Send
        //
        // public async Task<string> Send(string network, string seed, int index, string receiver, decimal amount, ulong nonce)
        // {
        //     var key = new Key(seed.HexDecode(), index);
        //     var wallet = key.ToWallet();
        //
        //     var txAmount = (ulong) (amount * (decimal) MoneyUnit.BTC);
        //
        //     var tx = new TransactionRequest()
        //         .AddSender(wallet.Base58Address, key, txAmount + Constants.Commission, nonce)
        //         .AddTransfer(receiver, txAmount)
        //         .Sign();
        //
        //     await _httpService.Send(network, tx);
        //     return tx.Hash;
        // }
        //
        // public async Task<string> Send(string network, string seed, int index, string receiver, decimal amount, bool useUnconfirmed = false)
        // {
        //     var key = new Key(seed.HexDecode(), index);
        //     var wallet = key.ToWallet();
        //
        //     var nonceDto = await _httpService.GetNonce(network, wallet.Base58Address);
        //     var nonce = nonceDto.ConfirmedNonce;
        //     if (useUnconfirmed)
        //     {
        //         nonce = nonceDto.UnconfirmedNonce;
        //     }
        //     var txAmount = (ulong) (amount * (decimal) MoneyUnit.BTC);
        //
        //     var tx = new TransactionRequest()
        //         .AddSender(wallet.Base58Address, key, txAmount + Constants.Commission, nonce)
        //         .AddTransfer(receiver, txAmount)
        //         .Sign();
        //
        //     await _httpService.Send(network, tx);
        //     return tx.Hash;
        // }
        //
        // #endregion

        #region Contracts

        public async Task <T> StaticCall <T>(string network, string address, ContractFunctionCall call)
        {
            var payload = call.ArgsCall.Aggregate(call.Function.NameHex, (current, argCall) => current + argCall.ToPayloadHex());

            var req = new ContractStaticCallRequestDto
            {
                Address = address,
                Payload = payload
            };
            var res = await _httpService.ContractStaticCall(network, req);

            return(res.Result.ConvertTo <T>());
        }
Exemplo n.º 3
0
        public async Task <ContractStaticCallResponseDto> ContractStaticCall(string network, ContractStaticCallRequestDto model)
        {
            const string url = "/contract/static_call";

            return(await Post <ContractStaticCallRequestDto, ContractStaticCallResponseDto>(network, url, model));
        }