0

每个人。我在 Avalanche 测试网上部署了这个智能合约。

contract Storage {

uint256 number;

/**
 * @dev Store value in variable
 * @param num value to store
 */
function store(uint256 num) public {
    number = num;
}

/**
 * @dev Return value 
 * @return value of 'number'
 */
function retrieve() public view returns (uint256){
    return number;
}

}

我正在尝试使用 Nethereum 调用写入函数(本合同中的“存储”)。

        Task<BigInteger> retrieveFunction = tmpContract.GetFunction("retrieve").CallAsync<BigInteger>();
        retrieveFunction.Wait();
        int result1 = (int)retrieveFunction.Result;


        //Prompts for the account address.
        Console.Write("Current stored amount: {0}\n", result1);
        string accountAddress = "0xa40e61095202Afe72dFfc4Aae70bc631429293B2";
                    
        BigInteger value = 450000;
        try
        {
            
            Task<string> storeFunction = tmpContract.GetFunction("store").SendTransactionAsync(accountAddress, value);
            storeFunction.Wait();
            Console.WriteLine("Succesfully Stored!");
        }
        catch (Exception e)
        {
            Console.WriteLine("Error: {0}", e.Message);
        }

结果,检索功能运行良好,但在存储功能方面发生错误。

4

0 回答 0