---
title: "Write Contract"
method: POST
path: "/v1/contracts/write"
tags: ["Wallets"]
---

# Write Contract

`POST /v1/contracts/write`

Executes write operations (transactions) on smart contracts. This is a convenience endpoint that simplifies contract interaction by accepting method signatures and parameters directly, without requiring manual transaction encoding. All calls are executed against the same contract address and chain, making it ideal for batch operations.

**Authentication**: This endpoint requires project authentication and wallet authentication. For backend usage, use `x-secret-key` header. For frontend usage, use `x-client-id` + `Authorization: Bearer <jwt>` headers.

## Request body

- object
  - `calls` object[], required — Array of contract method calls to execute. Each call specifies a contract address, method signature, and optional parameters.
    - `contractAddress` string, required — The smart contract address or ENS name.
    - `method` string, required — The contract function signature to call (e.g., 'function approve(address spender, uint256 amount)' or `function balanceOf(address)`). Must start with 'function' followed by the function name and parameters as defined in the contract ABI. For functions returning arrays of structs, use positional types only in the return declaration (e.g., `returns ((uint256, address, bool)[])` instead of `returns ((uint256 id, address owner, bool active)[] items)`).
    - `params` unknown[] — Array of parameters to pass to the contract method, in the correct order and format.
      - unknown
    - `value` string — Amount of native token to send with the transaction in wei. Required for payable methods.
  - `chainId` integer, required — The blockchain network identifier. Common values include: 1 (Ethereum), 8453 (Base), 137 (Polygon), 56 (BSC), 43114 (Avalanche), 42161 (Arbitrum), 10 (Optimism).
  - `from` string — The wallet address or ENS name that will send the transaction. If omitted, the project wallet will be used if available.
  - `idempotencyKey` string — An optional unique key to prevent duplicate transactions. If a request with the same idempotency key has already been submitted, the existing transaction will be returned instead of creating a new one.

## Response `200`

Contract write operations submitted successfully. Returns transaction IDs for tracking and monitoring.

- object
  - `result` object, required
    - `transactionIds` string[], required — Array of unique identifiers for the submitted transactions. Use these to track transaction status.

## Other responses

- `400` — Invalid request parameters. This occurs when contract parameters are malformed, method signatures are invalid, insufficient balance, or unsupported contract methods.
- `401` — Authentication required. For backend usage, include `x-secret-key` header. For frontend usage, include `x-client-id` + `Authorization: Bearer <jwt>` headers.
- `402` — Payment required. Insufficient wallet balance to complete the purchase.
- `404` — Contract not found. The specified contract address does not exist on the given blockchain network or is not accessible.
- `500` — Internal server error. This may occur due to blockchain connectivity issues, gas estimation failures, contract execution errors, or unexpected server errors.

---

[API](https://skmtc.net/thirdweb/apis/thirdweb-api.md) · [All operations](https://skmtc.net/thirdweb/apis/thirdweb-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/thirdweb/thirdweb-api/revisions/fb4cb67da1c7/schema)
