Beispiel #1
0
        public async Task <string> SendTransaction(
            byte[] privateKey, RawTransaction rawTransaction)
        {
            var result = await _service.SendTransactionAsync(privateKey, rawTransaction);

            return(result.ToString());
        }
        //public async Task<string> SendTransaction(
        //  byte[] privateKey, byte[] rawTransaction)
        //{

        //    var result = await _service.SendTransactionAsync(privateKey, rawTransaction);
        //    return result.ToString();

        //}

        public async Task <string> SendTransactionPtoP(
            byte[] senderPrivateKey, string sender, string reciver, ulong amount)
        {
            var senderAccount = await GetAccountInfoAsync(sender);

            RawTransactionLCS rawTr = new RawTransactionLCS()
            {
                ExpirationTime = (ulong)DateTimeOffset.UtcNow.AddSeconds(60)
                                 .ToUnixTimeSeconds(),
                GasUnitPrice   = 0,
                MaxGasAmount   = 100000,
                SequenceNumber = senderAccount.SequenceNumber
            };

            rawTr.TransactionPayload = new TransactionPayloadLCS();

            rawTr.TransactionPayload.PayloadType = (uint)ETransactionPayloadLCS.Script;
            rawTr.TransactionPayload.Script      = new ScriptLCS()
            {
                Code = Utility.PtPTrxBytecode,
                TransactionArguments = new List <TransactionArgumentLCS>()
                {
                    new TransactionArgumentLCS()
                    {
                        ArgType = (uint)ETransactionArgumentLCS.Address,
                        Address = new AddressLCS(reciver)
                    },
                    new TransactionArgumentLCS()
                    {
                        ArgType = (uint)ETransactionArgumentLCS.U64,
                        U64     = amount
                    }
                }
            };
            rawTr.Sender = new AddressLCS(sender);
            var result = await _service.SendTransactionAsync(senderPrivateKey, rawTr);

            return(result.ToString());
        }