# invokeRead

Execute a contract invocation in read-only mode.

## **Input Arguments**

<table><thead><tr><th width="289">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>scriptHash: string</code></td><td>Script hash of the smart contract to invoke a read on</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="#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>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></tbody></table>

## **Success Response**

The wallet will return the direct response from the RPC node.

<table><thead><tr><th width="294">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>script: string</code></td><td>The script which was run</td></tr><tr><td><code>state: string</code></td><td>Status of the executeion</td></tr><tr><td><code>gas_consumed: string</code></td><td>Estimated amount of GAS to be used to execute the invocation. (Up to 10 free per transaction)</td></tr><tr><td><code>stack:</code> <a href="#argument"><img src="http://localhost:8080/assets/images/info.svg" alt="i"></a><code>Argument[]</code></td><td>An array of response arguments</td></tr></tbody></table>

### Argument

<table><thead><tr><th width="387">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: string</code></td><td>String representation of the argument which you are using</td></tr></tbody></table>

## **Error Response**

<table><thead><tr><th width="273">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.invokeRead({
  scriptHash: '0x96ef49bb4f67e25235a4cd4455d2f10779186ab2',
  operation: 'balanceOf',
  args: [
    {
      type: 'Address',
      value: 'AY5xLg4RPZPcYoD1fW7j455PkAybbU2x42'
    }
  ]
})
.then(result => {
  console.log('Read invocation result: ' + JSON.stringify(result));
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case 'NO_PROVIDER':
        console.log('No provider available.');
        break;
    case 'CONNECTION_REFUSED':
        console.log('Connection dApp not connected. Please call the "connect" function.');
        break;
    case 'RPC_ERROR':
        console.log('There was an error when broadcasting this transaction to the network.');
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});
```

### Response

```js
{
  script: '14b2ed6ac7d282933322293e5a0c5c8bb12f9477f251c10962616c616e63654f6667b26a187907f1d25544cda43552e2674fbb49ef96',
  state: 'HALT',
  gas_consumed: '0.315',
  stack: [
    {
      type: 'ByteArray',
      value: '00902f5009'
    }
  ]
}
```
