# Transact to EVM Function

Transact to EVM Function is used to submit a transaction to a contract on a Testnet or Mainnet chain. Transact to EVM Function is useful for any midpoint that has a requirement to submit some sort of external data back on-chain, whenever you want to trigger your contract in response to an on-chain event, or when you need to call your contract at an interval.

There are two types of Transact to EVM Function tasks: Testnet and Mainnet. Testnet submits transactions to Testnet chains, and Mainnet submits transactions to Mainnet chains.

## **Definition**

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

**`chainId`: String.** The Chain ID of the chain to submit the transaction to. For a complete list of Chain Ids that we currently support, take a look at [chain-ids](https://docs.midpointapi.com/midpoint-documentation/more-reading/chain-ids "mention").

**`contractAddress`: String.** The address of the contract that Transact to EVM Function submits a transaction to. This contract address should exist on the chain you are calling.

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

**`arguments`:** This specifies both the signature of your on-chain function, and the values that are going to be submitted by the Transact to 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 that will be submitted. 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.value`: String.** This defines the value that will be submitted on-chain when your Transact to EVM Function submits a transaction. 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.

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

* **`Timestamp`** Unixtime of execution.
* **`Unit_Price_In_USD`** The unit price of the native token on the chain you submitted on. E.g. $1500 for Ethereum.
* **`Cumulative_Gas_Used`** The cumulative amount of gas used by the transaction.
* **`Txn_Hash`** The Transaction Hash of the transaction.
* **`Contract_Address`** The contract address that contained the EVM function.
* **`Gas_Used`** The gas that was used by the transaction.
* **`Block_Number`** The block number of the transaction.;

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

* **`TaskDefinition`** The complete definition of this task at runtime.
* **`ComposedResponseData`** The complete set of data that will be posted on-chain
* **`Txn_Hash`** The transaction hash and chainId of the submitted response&#x20;
* **`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.&#x20;

## Examples

This section is incomplete.

## Tips for Using Transact To 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](https://docs.midpointapi.com/midpoint-documentation/core-concepts/midpoints/midpoint-id "mention") as your first argument to ensure your smart contracts [security](https://docs.midpointapi.com/midpoint-documentation/tasks/transact-to-evm-function/security "mention").
* Use a variable for your chainId, and have it originate from on-chain. If you use the implicit **Chain\_ID** from your [startpoint-called](https://docs.midpointapi.com/midpoint-documentation/sources/startpoint-called "mention")source, you can have a chain-agnostic data bridge that uses the same midpoint.
