> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a transaction

> Creates an unsigned transaction for transferring assets to another address on a
specific chain. You can then use this unsigned transaction to sign and submit
the transaction.

The response shape varies depending on the chain type (EIP-155, Solana, Bitcoin,
Stellar, or Tron).




## OpenAPI

````yaml /openapi/custodian-api.yaml post /custodians/me/clients/{clientId}/chains/{chain}/assets/send/build-transaction
openapi: 3.1.0
info:
  title: Portal Custodian API
  version: '3.0'
  description: >
    The Portal Custodian API provides endpoints for managing clients, building
    transactions,

    retrieving wallet data, managing delegations, alert webhooks, and gas
    sponsorship.

    All endpoints require authentication via a Portal API Key (also known as a
    Custodian API Key)

    passed as a Bearer token.


    ## Base URL

    `https://api.portalhq.io/api/v3`


    ## Authentication

    Include your Portal API Key as a Bearer token in the `Authorization` header
    of every request.


    ## Chain ID Format

    Chain parameters use either friendly names (e.g. `ethereum`, `solana`) or
    CAIP-2 format

    (e.g. `eip155:1`, `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`). When using
    CAIP-2 format

    in URLs, ensure the colon is URI-encoded (`%3A`).
servers:
  - url: https://api.portalhq.io/api/v3
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Clients
    description: Create and manage Portal clients
  - name: Transactions
    description: Build and evaluate blockchain transactions
  - name: Wallet Metadata
    description: Retrieve wallet balances and NFTs
  - name: Wallet Shares
    description: Manage backup shares and wallet ejection
  - name: Delegations
    description: Manage token delegations and delegated transfers
  - name: Session Keys
    description: Build and send EIP-7702 session key user operations
  - name: Alert Webhooks
    description: Manage alert webhooks, external addresses, and replay failed events
  - name: Gas Sponsorship
    description: View and manage gas sponsorship across chains
paths:
  /custodians/me/clients/{clientId}/chains/{chain}/assets/send/build-transaction:
    post:
      tags:
        - Transactions
      summary: Build a transaction
      description: >
        Creates an unsigned transaction for transferring assets to another
        address on a

        specific chain. You can then use this unsigned transaction to sign and
        submit

        the transaction.


        The response shape varies depending on the chain type (EIP-155, Solana,
        Bitcoin,

        Stellar, or Tron).
      operationId: custodianBuildTransaction
      parameters:
        - $ref: '#/components/parameters/clientId'
        - $ref: '#/components/parameters/chain'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuildTransactionRequest'
            example:
              to: '0xdFd8302f44727A6348F702fF7B594f127dE3A902'
              token: USDC
              amount: '0.01'
      responses:
        '200':
          description: >
            Unsigned transaction built successfully. The response structure
            depends on the

            chain type.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/Eip155TransactionResult'
                  - $ref: '#/components/schemas/SolanaTransactionResult'
                  - $ref: '#/components/schemas/BitcoinTransactionResult'
              examples:
                eip155:
                  summary: EIP-155 (Ethereum, Polygon, Base, etc.)
                  value:
                    transaction:
                      from: '0x21d8d1d2d9907c051670d8c9a80bd2192d273f8d'
                      to: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
                      data: >-
                        0xa9059cbb000000000000000000000000dfd8302f44727a6348f702ff7b594f127de3a9020000000000000000000000000000000000000000000000000000000000002710
                    metadata:
                      rawAmount: '10000'
                      formattedAmount: '0.01'
                      tokenDecimals: 6
                      tokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
                solana:
                  summary: Solana
                  value:
                    transaction: >-
                      AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAUIdDKlh5tOZP...
                    metadata:
                      amount: '0.01'
                      mintAddress: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                      lastValidBlockHeight: '259030944'
                bitcoin:
                  summary: Bitcoin
                  value:
                    transaction:
                      signatureHashes:
                        - signatureHash1
                        - signatureHash2
                      rawTxHex: rawTxHex
                      publicKey: jsonStringifiedPublicKey
                    metadata:
                      chainId: bip122:000000000933ea01ad0ee984209779ba-p2wpkh
                      amount: '0.00001'
                      fromAddress: tb1qpl54na90wlmdxj5z4wtz7cpp6p32dc9tajwa5g
                      toAddress: tb1q7ynrnrywae5ypxk6fqgzqhqy202ehk7hntqc9j
                      rawAmount: '1000'
                      feeInSatoshis: '420'
                      changeInSatoshis: '4584'
                      tokenDecimals: 8
                      tokenSymbol: BTC
        '400':
          description: |
            Bad request - invalid parameters. Common causes include:
            - Invalid destination address format
            - Amount must be greater than zero
            - Unsupported chain
            - Token not supported on the specified chain
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - invalid or missing authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    clientId:
      name: clientId
      in: path
      required: true
      description: The unique identifier of the client.
      schema:
        type: string
    chain:
      name: chain
      in: path
      required: true
      description: >
        The blockchain chain identifier. Use either a friendly name or CAIP-2
        format.

        When using CAIP-2 format in URLs, ensure the colon (`:`) is URI-encoded
        as `%3A`.


        **Supported chains:**

        - `ethereum` (`eip155:1`)

        - `sepolia` (`eip155:11155111`)

        - `base` (`eip155:8453`)

        - `base-sepolia` (`eip155:84532`)

        - `polygon` (`eip155:137`)

        - `polygon-amoy` (`eip155:80002`)

        - `celo` (`eip155:42220`)

        - `celo-alfajores` (`eip155:44787`)

        - `monad` (`eip155:143`)

        - `monad-testnet` (`eip155:10143`)

        - `solana` (`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`)

        - `solana-devnet` (`solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`)

        - `tron` (`tron:mainnet`)

        - `tron-nile` (`tron:nile`)

        - `tron-shasta` (`tron:shasta`)

        - `stellar` (`stellar:pubnet`)

        - `stellar-testnet` (`stellar:testnet`)

        - `bitcoin-segwit` (`bip122:000000000019d6689c085ae165831e93-p2wpkh`)

        - `bitcoin-segwit-testnet`
        (`bip122:000000000933ea01ad0ee984209779ba-p2wpkh`)
      schema:
        type: string
      examples:
        ethereum:
          value: ethereum
          summary: Ethereum mainnet (friendly name)
        eip155:
          value: eip155:1
          summary: Ethereum mainnet (CAIP-2)
        solana:
          value: solana
          summary: Solana mainnet (friendly name)
  schemas:
    BuildTransactionRequest:
      type: object
      required:
        - to
        - token
        - amount
      properties:
        to:
          type: string
          description: The recipient's wallet address.
        token:
          type: string
          description: |
            The token symbol (e.g. `USDC`) or contract/mint address.
        amount:
          type: string
          description: |
            The amount to transfer in the token's primary denomination.
            Must be greater than zero.
    Eip155TransactionResult:
      type: object
      properties:
        transaction:
          type: object
          properties:
            from:
              type: string
            to:
              type: string
            data:
              type: string
        metadata:
          type: object
          properties:
            rawAmount:
              type: string
            formattedAmount:
              type: string
            tokenDecimals:
              type: integer
            tokenAddress:
              type: string
    SolanaTransactionResult:
      type: object
      properties:
        transaction:
          type: string
          description: Base64-encoded Solana transaction
        metadata:
          type: object
          properties:
            amount:
              type: string
            mintAddress:
              type: string
            lastValidBlockHeight:
              type: string
    BitcoinTransactionResult:
      type: object
      properties:
        transaction:
          type: object
          properties:
            signatureHashes:
              type: array
              items:
                type: string
            rawTxHex:
              type: string
            publicKey:
              type: string
        metadata:
          type: object
          properties:
            chainId:
              type: string
            amount:
              type: string
            fromAddress:
              type: string
            toAddress:
              type: string
            rawAmount:
              type: string
            feeInSatoshis:
              type: string
            changeInSatoshis:
              type: string
            tokenDecimals:
              type: integer
            tokenSymbol:
              type: string
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message describing what went wrong
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        Portal API Key (Custodian API Key). Pass as a Bearer token in the
        Authorization header.

````