# invoke

Invoke allows for the generic execution of smart contracts on behalf of the user. It is reccommended to have a general understanding of the NEO blockchain, and to be able successfully use all other commands listed previously in this document before attempting a generic contract execution.

## **Input Arguments**

<table><thead><tr><th width="366">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>scriptHash: string</code></td><td>Script hash of the smart contract to invoke</td></tr><tr><td><code>operation: string</code></td><td>Operation on the smart contract to call</td></tr><tr><td><code>args:</code> <a href="/pages/dd4fA3fJcWzaURDPJghn#argument"><img src="http://localhost:8080/assets/images/info.svg" alt="i"></a><code>Argument[]</code></td><td>Any input arguments for the operation</td></tr><tr><td><code>fee?: string</code></td><td>The parsed amount of network fee (in GAS) to include with transaction</td></tr><tr><td><code>network?: string</code></td><td>Network to submit this request to. If omitted, will default to network the wallet is currently set to</td></tr><tr><td><code>attachedAssets?:</code> <a href="/pages/dd4fA3fJcWzaURDPJghn#attachedassets"><img src="http://localhost:8080/assets/images/info.svg" alt="i"></a><code>AttachedAssets</code></td><td>Describes the assets to attach with the smart contract, e.g. attaching assets to mint tokens during a token sale</td></tr><tr><td><code>assetIntentOverrides?:</code> <a href="/pages/dd4fA3fJcWzaURDPJghn#assetintentoverrides"><img src="http://localhost:8080/assets/images/info.svg" alt="i"></a><code>AssetIntentOverrides</code></td><td><p>A hard override of all transaction utxo inputs and outputs.</p><p>IMPORTANT: If provided, fee and attachedAssets will be ignored.</p></td></tr><tr><td><code>triggerContractVerification?: boolean</code></td><td>Adds the instruction to invoke the contract verification trigger</td></tr><tr><td><code>broadcastOverride?: boolean</code></td><td>In the case that the dApp would like to be responsible for broadcasting the signed transaction rather than the wallet provider</td></tr><tr><td><code>txHashAttributes?:</code> <a href="/pages/dd4fA3fJcWzaURDPJghn#txhashattribute"><img src="http://localhost:8080/assets/images/info.svg" alt="i"></a><code>TxHashAttribute[]</code></td><td>Adds transaction attributes for the "Hash" usage block</td></tr></tbody></table>

### Argument

<table><thead><tr><th width="390">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type: 'String' | 'Boolean' | 'Hash160' | 'Hash256' | 'Integer' | 'ByteArray' | 'Array' | 'Address'</code></td><td>The type of the argument with you are using</td></tr><tr><td><code>value: any</code></td><td>String representation of the argument which you are using</td></tr></tbody></table>

### TxHashAttribute

| Parameter                                                                                                                                                                              | Description                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `type: 'String' \| 'Boolean' \| 'Hash160' \| 'Hash256' \| 'Integer' \| 'ByteArray' \| 'Array' \| 'Address'`                                                                            | The type of the argument with you are using               |
| `value: any`                                                                                                                                                                           | String representation of the argument which you are using |
| `txAttrUsage: 'Hash1' \| 'Hash2' \| 'Hash3' \| 'Hash4' \| 'Hash5' \| 'Hash6' \| 'Hash7' \| 'Hash8' \| 'Hash9' \| 'Hash10' \| 'Hash11' \| 'Hash12' \| 'Hash13' \| 'Hash14' \| 'Hash15'` | Attribute usage value                                     |

### AttachedAssets

<table><thead><tr><th width="267">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>NEO?: string</code></td><td>The amount of NEO to attach to the contract invocation</td></tr><tr><td><code>GAS?: string</code></td><td>The amount of GAS to attach to the contract invocation</td></tr></tbody></table>

### AssetIntentOverrides

<table><thead><tr><th width="328">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>inputs:</code> <a href="/pages/dd4fA3fJcWzaURDPJghn#assetinput"><img src="http://localhost:8080/assets/images/info.svg" alt="i"></a><code>AssetInput[]</code></td><td>A list of UTXO inputs to use for this transaction</td></tr><tr><td><code>outputs:</code> <a href="/pages/dd4fA3fJcWzaURDPJghn#assetoutput"><img src="http://localhost:8080/assets/images/info.svg" alt="i"></a><code>AssetOutput[]</code></td><td>A list of UTXO outputs to use for this transaction</td></tr></tbody></table>

### AssetInput

<table><thead><tr><th width="230">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>txid: string</code></td><td>Transaction id to be used as input</td></tr><tr><td><code>index: number</code></td><td>Index of the UTXO, can be found from transaction details</td></tr></tbody></table>

### AssetOutput

<table><thead><tr><th width="258">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>asset: string</code></td><td>Asset of the UTXO</td></tr><tr><td><code>address: string</code></td><td>Address to receive the UTXO</td></tr><tr><td><code>value: string</code></td><td>String representation of double or integer value to be used as output</td></tr></tbody></table>

## **Success Response**

In the case where the "broadcastOverride" input argument is not set, or set to false.

<table><thead><tr><th width="275">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>txid: string</code></td><td>The transaction ID of the invocation</td></tr><tr><td><code>nodeURL: string</code></td><td>The node which the transaction was broadcast to. Returned if transaction is broadcast by wallet provider</td></tr></tbody></table>

In the case where the "broadcastOverride" input argument is set to True.

<table><thead><tr><th width="256">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>txid: string</code></td><td>The transaction ID of the invocation</td></tr><tr><td><code>signedTx: string</code></td><td>The serialized signed transaction. Only returned if the broadcastOverride input argument was set to True</td></tr></tbody></table>

## **Error Response**

<table><thead><tr><th width="289">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type: string</code></td><td>The type of error which has occured</td></tr><tr><td><code>description: string</code></td><td>A description of the error which has occured</td></tr><tr><td><code>data: string</code></td><td>Any raw data associated with the error</td></tr></tbody></table>

## Example

### Request

```js
neoline.invoke({
  scriptHash: 'af7c7328eee5a275a3bcaee2bf0cf662b5e739be',
  operation: 'balanceOf',
  args: [
    {
      type: 'Hash160',
      value: '91b83e96f2a7c4fdf0c1688441ec61986c7cae26'
    }
  ],
  attachedAssets: {
    NEO: '1',
    GAS: '0.0001'
  },
  fee: '0.001',
  network: 'TestNet',
  broadcastOverride: false,
  txHashAttributes: [
    {
      type: 'Boolean',
      value: true,
      txAttrUsage: 'Hash1'
    }
  ]
})
.then(result => {
  console.log('Invoke transaction success!');
  console.log('Transaction ID: ' + result.txid);
  console.log('RPC node URL: ' + result.nodeURL);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'NO_PROVIDER':
        console.log('No provider available.');
        break;
    case 'RPC_ERROR':
        console.log('There was an error when broadcasting this transaction to the network.');
        break;
    case 'CANCELED':
        console.log('The user has canceled this transaction.');
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});
```

### Response

```js
{
  txid: 'd08c5f58675376832480f2959732caa2a0e024ad0304ed77c62146a9621124d6',
  nodeUrl: 'https://testnet.api.neoline.io'
};
```


---

# 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://tutorial.neoline.io/reference/neo2-provider-api/write-methods/invoke.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.
