> For the complete documentation index, see [llms.txt](https://docs.usemeta.fi/js-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usemeta.fi/js-sdk/sdk-reference/callgenericreadfunction.md).

# CallGenericReadFunction

## Description

This allows you to call any read-only smart contract function that does not require the user to sign the transaction. It can be invoked even before the user is logged in.

### Signature

`async CallGenericReadFunction(args, apiKey)`

### Arguments

<table><thead><tr><th width="258">Parameter</th><th width="114">Type</th><th>Definition</th></tr></thead><tbody><tr><td><code>args.contractAddress</code></td><td>String</td><td>Contract address of the smart contract to be called</td></tr><tr><td><code>args.functionABI</code></td><td>JSON</td><td>The JSON object for the <a href="https://ethereum.org/en/developers/docs/smart-contracts/compiling/#web-applications">smart contract ABI</a></td></tr><tr><td><code>args.functionName</code></td><td>String</td><td>Name of the function to be called</td></tr><tr><td><code>args.chain</code></td><td>chain (class)</td><td>Which chain the smart contract is deployed on. Pick a chain from the <a href="/pages/RsPwmVr7xSQeT0vZHluX">supported chains list</a></td></tr><tr><td><code>args.params</code></td><td>array</td><td>Array of objects that will be sent as the arguments to the smart contract function. Please ensure that the order of params matches the contract ABI.<br><br>For large numerical inputs, please refer to the <a href="#handling-numerical-values">section below</a>.</td></tr><tr><td><code>apiKey</code></td><td>String</td><td>The API Key generated from the <a href="https://developer-test.usemeta.fi/">Developer Portal</a></td></tr></tbody></table>

### Return Value

Object returned from smart contract.

```json
{
    "statusCode": 1/0,
    "data": "data" // the data returned from the smart contract function
    "error": "error" // error if any
}
```

### Handling Large Numerical Values

{% hint style="warning" %}
Applicable to EVM Chains only
{% endhint %}

While passing in large numerical values (values above **9007199254740991**) in `args.params`, a conversion to BigNumber format needs to be made. You can use the following methods that convert the number to and from the appropriate format:

`ConvertNumberToBigNumber(number, decimal)` - Use this method while passing in numbers as params to a smart function that requires uint256 numbers

`ConvertBigNumberToNumber(bigNumber, decimal)` - Use this method while converting response values from a smart contract function call (which are in bigNumber format) to a JS Number

## Example

{% code lineNumbers="true" %}

```jsx
import { 
    CallGenericReadFunction, 
    chains 
} from '@metafi/metafi-js-sdk';
import stakeContractAbi from '../contracts/abi/stakeContract.json';

function App() {

    const getStakedBalance = async () => {
        let result = await CallGenericReadFunction({
            chain: chains.eth,             
            contractAddress: "0xF5C9F957705bea56a7e806943f98F7877B995826",   
            functionABI: stakeContractAbi.abi,   
            functionName: "getStakedAmount",
            params: ["0x40562Cf2E90f23b3969d782B5d8f134A77069b49"],               
        });
        
        console.log(
            'staked value is: ', 
            ConvertBigNumberToNumber(result.data, 18),
        );
    }
    
    return (
        <>
           <button onClick={getStakedBalance}>Get User Staked Balance</button>
        </>
    );
};
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.usemeta.fi/js-sdk/sdk-reference/callgenericreadfunction.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
