0

i'am trying to call smart contract function in test network "Ropsten" https://ropsten.etherscan.io/address/0xa89d48b51801b61b27f9dee744b888ae152c2115 (few failed transaction is just testing with empty data from metamask)

But there is nothing happening and no any error. What am i doing wrong? As i know infura not allowed to send private key so it means that i should send signed transaction.

Code of Solidity function

    function joinTo(address payable _parent) payable public{
    require(msg.value == prices[0],"wrong ether amount");
    require(nodes[msg.sender].level == 0, "already connected");
    address payable parent = findAvailableNode(_parent);
    Node storage node = nodes[parent];
    if(node.descendant1 == address(0)){
        node.descendant1 = msg.sender;
    } else if(node.descendant2 == address(0)) {
        node.descendant2 = msg.sender;
    } else if(node.descendant3 == address(0)) {
        node.descendant3 = msg.sender;
    } else revert("there are no empty descendant");
    parent.transfer(1e18);
    nodes[msg.sender] = Node(1, parent, address(0),address(0),address(0));

    emit Joined(msg.sender, parent);
}

C# code

public async void JoinTo(Account account,string address)
    {
        var web3 = new Web3(account,Global.node);
        var transferHandler = web3.Eth.GetContractTransactionHandler<joinToFunction>();
        var transfer = new joinToFunction()
        {
            Parent = address
        };
        transfer.Gas = 900000;
        transfer.AmountToSend = Web3.Convert.ToWei(1);
        transfer.GasPrice = Web3.Convert.ToWei(25, UnitConversion.EthUnit.Gwei);
        transfer.Nonce = 10;
        var signedTransaction1 = await transferHandler.SignTransactionAsync(Global.contractAddress, transfer);

       // var signedTransaction2 = await transferHandler.SignTransactionAsync(Global.contractAddress, transfer);
       // var transactionIdPredicted = Sha3Keccack.Current.CalculateHashFromHex(signedTransaction1);
        var transactionIdActual =
            await web3.Eth.Transactions.SendRawTransaction.SendRequestAsync("0x" + signedTransaction1);
    }
    [Function("joinTo")]
    public class joinToFunction : FunctionMessage
    {
        [Parameter("address", "_parent", 1)]
        public string Parent { get; set; }

    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.