# Call EVM Function

The Call EVM Function task allows you to obtain any on-chain data to your midpoint by doing a direct RPC call to an on-chain view function. This task is used in a wide variety of workflows, such as cross-chain data bridging and retrieving values from any other chain back onto the chain your application lives on.

## **Definition**

```graphql
chainId: string # required
contractAddress: string # required
functionName: string # required
arguments: [
    {
        name: string
        datatype: string
        value: string
    }
]
returnValues: [ # at least one value is required
    {
        name: string
        datatype: string
    }
]
extracts: [
    {
        name: string
        from: string
    }
]
excludeLogs: [string]
```

**`chainId`: String.** The Chain ID of the chain to request data from. For a complete list of Chain Ids that we currently support, take a look at [Chain IDs](/midpoint-documentation/more-reading/chain-ids.md).

**`contractAddress`: String.** The address of the contract that Call EVM Function calls. This contract address should exist on the chain you are calling.

**`functionName`: String.** This is name of the function you are calling from the Call EVM Function task.&#x20;

**`arguments`:** This specifies both the signature of your on-chain function, and any values that are going to be submitted by the Call EVM Function task.

**`arguments.name`: String.** This is the name of the argument that you are passing in. This is a human-readable name that you set: for clarity, it might be best to set this name to the name of the parameter you are calling.&#x20;

**`arguments.datatype`: String.** This defines the solidity datatype of the value that is passed into the on-chain function. This datatype must match the datatype of your on-chain function exactly, in the same order as they are defined in the on-chain function.

**`arguments.from`: String.** This defines the value that will be submitted on-chain when your Call EVM Function does a call. If you directly put in a value, it will be a constant that is always submitted. We recommend entering a variable name that will be interpolated during runtime after it is extracted from a previous source or task.

**`returnValues`: String**This specifies the return values that will be returned after you call your EVM function. These values will be automatically extracted as a variable to be used by downstream tasks.

**`returnValues.name`: String.** This is the name of the argument that is being returned in. This is a human-readable name that you set, which will be the name of the variable that is generated.

**`returnValues.datatype`: String.** This defines the solidity datatype of the value that is returned by the on-chain function. This datatype must match the datatype of your on-chain function's return values exactly, in the same order as they are defined in the on-chain function.

**`extracts`: See** [**extracts**](/midpoint-documentation/core-concepts/midpoints/source-and-task-definitions/extracts.md)**.** Legal values:

* **`Timestamp`** Unixtime of execution.

**`excludeLogs`: See** [**exclude logs**](/midpoint-documentation/core-concepts/midpoints/source-and-task-definitions/exclude-logs.md)**.** Legal values:

* **`TaskDefinition`** The complete definition of this task at runtime.
* **`TaskOutputData`** The complete set of returned values from this task.

## Returned Values

This task returns any values extracted using the `extracts` which are outlined above. Additionally, this task returns any values defined in returnValues, where the name of the variable created is the name specified by the user.

## Examples

This section is incomplete.

## Tips for Using Call Evm Function

* Use a variable from a source or a previous task for the value of an argument. This makes the values that you submit back on-chain dynamic.
* Use your [Midpoint ID](/midpoint-documentation/core-concepts/midpoints/midpoint-id.md) as your first argument to ensure your smart contracts [Security](/midpoint-documentation/tasks/transact-to-evm-function/security.md).
* Use a variable for your chainId, and have it originate from on-chain. If you use the implicit **Chain\_ID** from your [Startpoint Called](/midpoint-documentation/sources/startpoint-called.md)source, you can have a chain-agnostic data bridge that uses the same midpoint.


---

# Agent Instructions: 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:

```
GET https://docs.midpointapi.com/midpoint-documentation/tasks/call-evm-function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
