# Read from a smart contract — Overledger

> Reads data from a specified smart contract on the Overledger network.

- Key: `overledger-read-from-a-smart-contract`
- Type: Action (Read-only)
- Version: 0.0.3
- App: Overledger (`overledger`) — https://pipedream.com/apps/overledger.md
- This page (HTML): https://pipedream.com/apps/overledger/actions/read-from-a-smart-contract
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/overledger/actions/read-from-a-smart-contract/read-from-a-smart-contract.mjs

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `environment` | `string` | Yes | Select the Overledger instance to be used |
| `locationTechnology` | `string` | Yes | The technology of the blockchain that the transaction will be submitted to |
| `functionName` | `string` | Yes | The name of the function to call on the smart contract. |
| `inputParameters` | `string[]` | No | The input parameters for the smart contract function, provide both type and value in object format. Example: {"type":"uint256","value":"5"} or {"type":"address","value":"0x3....ed8"} |
| `smartContractId` | `string` | Yes | The ID/address of the smart contract to interact with. |
| `outputParameters` | `string[]` | No | Each output parameter expected, provide just the type in object format. Example - 1) function returns one uint256 value: {"type": "uint256"} or 2) function returns two address values: {"type": "address"},{"type": "address"} |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "overledger",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "overledger-read-from-a-smart-contract",
  arguments: {
    environment: "Overledger Instance",
    locationTechnology: "Location Technology",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "overledger-read-from-a-smart-contract",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    overledger: { authProvisionId: "apn_xxxxxxx" },
    environment: "Overledger Instance",
    locationTechnology: "Location Technology",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "overledger-read-from-a-smart-contract",
    "configured_props": {
      "overledger": { "authProvisionId": "apn_xxxxxxx" },
      "environment": "Overledger Instance",
      "locationTechnology": "Location Technology"
    }
  }'
```

---

- App: https://pipedream.com/apps/overledger.md · All apps: https://pipedream.com/apps
