internal static CallContractParams CallContractParameters(CallContractParams callParameters)
 {
     if (callParameters is null)
     {
         throw new ArgumentNullException(nameof(callParameters), "The call parameters are missing. Please check that the argument is not null.");
     }
     return(callParameters);
 }
예제 #2
0
 protected async Task HandleValidSubmit()
 {
     _output = null;
     await _network.ExecuteAsync(_input.Gateway, _input.Payer, async client =>
     {
         var callParams = new CallContractParams
         {
             Contract      = _input.Contract,
             Gas           = _input.Gas.GetValueOrDefault(),
             PayableAmount = _input.Amount.GetValueOrDefault(),
             FunctionName  = _input.FunctionName,
             FunctionArgs  = _input.Arguments.ToArray()
         };
         _output = await client.CallContractWithRecordAsync(callParams, ctx => ctx.Memo = _input.Memo?.Trim());
     });
 }
예제 #3
0
 /// <summary>
 /// Calls a smart contract returning if successful.  The CallContractReceipt
 /// will include the details of the results from the call, including the
 /// output parameters returned by the function call.
 /// </summary>
 /// <param name="callParameters">
 /// An object identifying the function to call, any input parameters and the
 /// amount of gas that may be used to execute the request.
 /// </param>
 /// <param name="configure">
 /// Optional callback method providing an opportunity to modify
 /// the execution configuration for just this method call.
 /// It is executed prior to submitting the request to the network.
 /// </param>
 /// <returns>
 /// A contract transaction record indicating success, it also
 /// any output parameters sent from the contract function.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">If required arguments are missing.</exception>
 /// <exception cref="InvalidOperationException">If required context configuration is missing.</exception>
 /// <exception cref="PrecheckException">If the gateway node create rejected the request upon submission.</exception>
 /// <exception cref="ConsensusException">If the network was unable to come to consensus before the duration of the transaction expired.</exception>
 /// <exception cref="TransactionException">If the network rejected the create request as invalid or had missing data.</exception>
 public async Task <CallContractRecord> CallContractWithRecordAsync(CallContractParams callParameters, Action <IContext>?configure = null)
 {
     return(new CallContractRecord(await ExecuteTransactionAsync(new ContractCallTransactionBody(callParameters), configure, true, callParameters.Signatory).ConfigureAwait(false)));
 }
예제 #4
0
 /// <summary>
 /// Calls a smart contract returning a receipt indicating success.
 /// This can be used for contract calls that do not return data.
 /// If the contract returns data, call the <see cref="CallContractWithRecordAsync"/>
 /// call instead to retrieve the information returned from the function call.
 /// </summary>
 /// <param name="callParameters">
 /// An object identifying the function to call, any input parameters and the
 /// amount of gas that may be used to execute the request.
 /// </param>
 /// <param name="configure">
 /// Optional callback method providing an opportunity to modify
 /// the execution configuration for just this method call.
 /// It is executed prior to submitting the request to the network.
 /// </param>
 /// <returns>
 /// A contract transaction receipt indicating success, it does not
 /// include any output parameters sent from the contract.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">If required arguments are missing.</exception>
 /// <exception cref="InvalidOperationException">If required context configuration is missing.</exception>
 /// <exception cref="PrecheckException">If the gateway node create rejected the request upon submission.</exception>
 /// <exception cref="ConsensusException">If the network was unable to come to consensus before the duration of the transaction expired.</exception>
 /// <exception cref="TransactionException">If the network rejected the create request as invalid or had missing data.</exception>
 public async Task <TransactionReceipt> CallContractAsync(CallContractParams callParameters, Action <IContext>?configure = null)
 {
     return(new TransactionReceipt(await ExecuteTransactionAsync(new ContractCallTransactionBody(callParameters), configure, false, callParameters.Signatory).ConfigureAwait(false)));
 }