[#RPCMethod-Arg]
= xref:RPCMethod.adoc[RPCMethod]::Arg
:relfileprefix: ../
:mrdocs:

Helper to get a required or default&hyphen;valued request argument&period;

== Synopsis

Declared in `&lt;rpc&sol;util&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename R&gt;
auto
Arg(std::string&lowbar;view key) const;
----

== Description

Use this function when the argument is required or when it has a default value&period; If the argument is optional and may not be provided, use MaybeArg instead&period;

This function only works during m&lowbar;fun(), i&period;e&period;, it should only be used in RPC method implementations&period; It internally checks whether the user&hyphen;passed argument isNull() and parses (from JSON) and returns the user&hyphen;passed argument, or the default value derived from the RPCArg documentation&period;

The instantiation of this helper for type R must match the corresponding RPCArg&colon;&colon;Type&period;

== Return Value

The value of the RPC argument (or the default value) cast to type R&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| The name of the argument to fetch&period;
|===

== See Also

MaybeArg for handling optional arguments without default values&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
