Esempio n. 1
0
        public async Task <ReturnObject> TestSmartContractFunction()
        {
            try
            {
                //  var unlockResult = await web3.Personal.UnlockAccount.SendRequestAsync(senderAddress, password, new HexBigInteger(120));
                //  Assert.True(unlockResult);
                // bool unlockResult = await Web3Api.UnlockAccount(AppSettingHelper.GetSmartContractPublicKey(), AppSettingHelper.GetSmartContractPrivateKey(), 120);
                string abi = AppSettingHelper.GetSmartContractAbi();
                Nethereum.Contracts.Contract contract =
                    Web3Api.GetContract(abi, AppSettingHelper.GetSmartContractAddress());
                Function funct1  = Web3Api.getFunction(contract, "balanceDollars");
                var      result1 = await funct1.CallAsync <BigInteger>("0xc942F1D286d9b8002206CbB3196f46Fa892aAD93");

                Function funct  = Web3Api.getFunction(contract, "transfer");
                var      _thing = await funct.SendTransactionAndWaitForReceiptAsync(
                    AppSettingHelper.GetSmartContractPublicKey(), null, "0xc942F1D286d9b8002206CbB3196f46Fa892aAD93",
                    100000000000000);

                // var result = await funct.CallDeserializingToObjectAsync<bool>("0xc942F1D286d9b8002206CbB3196f46Fa892aAD93", 100000000000000);
                Console.WriteLine(_thing);
                return(new ReturnObject
                {
                    Status = Status.STATUS_COMPLETED,
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(new ReturnObject
                {
                    Status = Status.STATUS_ERROR,
                    Message = e.Message
                });
            }
        }
Esempio n. 2
0
        public List <ParameterOutput> DecodeInput(string input)
        {
            string abi = AppSettingHelper.GetSmartContractAbi();

            Nethereum.Contracts.Contract
                     contract = Web3Api.GetContract(abi, AppSettingHelper.GetSmartContractAddress());
            Function funct    = Web3Api.getFunction(contract, "transferFromByOwner");

            return(Web3Api.DecodeInput(input, funct));
        }