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

# Encode a Transaction

> Encodes transaction data into a format suitable for broadcasting. This function is pivotal for creating transactions that comply with the specific requirements of different blockchains.        It also completes the input transaction with computed data, such as fees and max spendable amount, and performs some chain-specific validation checks on the transaction.



## OpenAPI

````yaml openapi.json post /api/{chainId}/transaction/encode
openapi: 3.1.0
info:
  title: Adamik
  version: 0.1.0
  description: Adamik API reference
servers:
  - url: https://api.adamik.io
security:
  - ApiKeyAuth: []
paths:
  /api/{chainId}/transaction/encode:
    post:
      tags:
        - Transaction
      summary: Encode a Transaction
      description: >-
        Encodes transaction data into a format suitable for broadcasting. This
        function is pivotal for creating transactions that comply with the
        specific requirements of different blockchains.        It also completes
        the input transaction with computed data, such as fees and max spendable
        amount, and performs some chain-specific validation checks on the
        transaction.
      parameters:
        - in: path
          name: chainId
          schema:
            type: string
            enum:
              - algorand
              - cosmoshub
              - cosmoshub-testnet
              - osmosis
              - osmosis-testnet
              - celestia
              - celestia-testnet
              - dydx
              - axelar
              - ethereum
              - sepolia
              - holesky
              - zksync
              - zksync-sepolia
              - injective-evm-testnet
              - base
              - base-sepolia
              - optimism
              - optimism-sepolia
              - arbitrum
              - arbitrum-sepolia
              - bitcoin
              - bitcoin-testnet
              - bitcoin-signet
              - polygon
              - polygon-amoy
              - bsc
              - bsc-testnet
              - linea
              - linea-sepolia
              - avalanche
              - avalanche-fuji
              - gnosis
              - gnosis-chiado
              - moonbeam
              - moonriver
              - moonbase
              - fantom
              - mantle
              - litecoin
              - dogecoin
              - ton
              - chiliz
              - chiliz-testnet
              - injective
              - akash
              - band
              - dymension
              - kyve
              - neutron
              - terra2
              - stargaze
              - tron
              - evmos
              - irisnet
              - juno
              - lum-network
              - omniflix
              - sei
              - medibloc
              - passage
              - quasar
              - seda
              - sommelier
              - shentu
              - stride
              - chihuahua
              - bitsong
              - persistence
              - comdex
              - fetch-ai
              - humans-ai
              - ki
              - likecoin
              - mars-hub
              - provenance
              - quicksilver
              - saga
              - ux-chain
              - kava
              - starknet
              - babylon
              - babylon-testnet
              - monad-testnet
              - berachain
              - berachain-artio
              - cronos
              - world-chain
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                transaction:
                  type: object
                  properties:
                    data:
                      allOf:
                        - type: object
                          properties:
                            memo:
                              type: string
                              description: >-
                                Optional free text field, that is supported for
                                some chains.
                            format:
                              type: string
                              enum:
                                - json
                                - hex
                              description: >-
                                Controls the format of the returned encoded
                                transaction. DEPRECATED, will be reworked at
                                some point.
                        - oneOf:
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: deployAccount
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                contractType:
                                  type: string
                                  enum:
                                    - argentx
                                  description: >-
                                    Provider of the account contract. Only
                                    ArgentX is supported at the moment.
                                  default: argentx
                              required:
                                - mode
                                - senderPubKey
                              title: Deploy Account
                              description: Deploy a smart contract wallet account
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: transfer
                                senderAddress:
                                  type: string
                                  description: Address or ID of the sender account.
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                recipientAddress:
                                  type: string
                                  description: Address or ID of the recipient account.
                                amount:
                                  type: string
                                  description: >-
                                    Optional amount to use (always in smallest
                                    unit). Use either this or useMaxAmount.
                                useMaxAmount:
                                  type: boolean
                                  description: >-
                                    Option to let the API compute the amount to
                                    use all available funds. Either use this or
                                    provide amount.
                                  default: false
                              required:
                                - mode
                                - senderAddress
                                - recipientAddress
                              title: Transfer
                              description: Transfer chain native coins
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: stake
                                senderAddress:
                                  type: string
                                  description: Address or ID of the sender account.
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                sourceValidatorAddress:
                                  type: string
                                  description: >-
                                    Address or ID of a validator. Can be used to
                                    move staking funds from this validator
                                    instead of the sender's balance, if
                                    supported by the chain.
                                targetValidatorAddress:
                                  type: string
                                  description: Address or ID of a validator
                                amount:
                                  type: string
                                  description: >-
                                    Optional amount to use (always in smallest
                                    unit). Use either this or useMaxAmount.
                                useMaxAmount:
                                  type: boolean
                                  description: >-
                                    Option to let the API compute the amount to
                                    use all available funds. Either use this or
                                    provide amount.
                                  default: false
                              required:
                                - mode
                                - senderAddress
                                - targetValidatorAddress
                              title: Stake
                              description: Put some funds at stake
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: transferToken
                                tokenId:
                                  type: string
                                  description: >-
                                    Unique ID of the token to transfer (e.g
                                    contract address for EVM chains)
                                senderAddress:
                                  type: string
                                  description: Address or ID of the sender account.
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                recipientAddress:
                                  type: string
                                  description: Address or ID of the recipient account.
                                amount:
                                  type: string
                                  description: >-
                                    Optional amount to use (always in smallest
                                    unit). Use either this or useMaxAmount.
                                useMaxAmount:
                                  type: boolean
                                  description: >-
                                    Option to let the API compute the amount to
                                    use all available funds. Either use this or
                                    provide amount.
                                  default: false
                              required:
                                - mode
                                - tokenId
                                - senderAddress
                                - recipientAddress
                              title: Transfer Token
                              description: Transfer chain tokens
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: unstake
                                senderAddress:
                                  type: string
                                  description: Address or ID of the sender account.
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                validatorAddress:
                                  type: string
                                  description: Address or ID of a validator
                                stakeId:
                                  type: string
                                  description: >-
                                    Unique identifier of a staking position.
                                    Only required for Babylon staking at the
                                    moment (documentation will come soon).
                                amount:
                                  type: string
                                  description: >-
                                    Optional amount to use (always in smallest
                                    unit). Use either this or useMaxAmount.
                                useMaxAmount:
                                  type: boolean
                                  description: >-
                                    Option to let the API compute the amount to
                                    use all available funds. Either use this or
                                    provide amount.
                                  default: false
                              required:
                                - mode
                                - senderAddress
                                - validatorAddress
                              title: Unstake
                              description: Stop staking some funds
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: claimRewards
                                senderAddress:
                                  type: string
                                  description: Address or ID of the sender account.
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                validatorAddress:
                                  type: string
                                  description: Address or ID of a validator
                                stakeId:
                                  type: string
                                  description: >-
                                    Unique identifier of a staking position.
                                    Only required for Babylon staking at the
                                    moment (documentation will come soon).
                                compound:
                                  type: boolean
                                  description: >-
                                    When available for the chain, controls
                                    whether staking rewards are cashed or added
                                    to the staked funds.
                                  default: false
                              required:
                                - mode
                                - senderAddress
                                - validatorAddress
                              title: Claim Rewards
                              description: Retrieve rewards from staking
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: withdraw
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                validatorAddress:
                                  type: string
                                  description: Address or ID of a validator
                                stakeId:
                                  type: string
                                  description: >-
                                    Unique identifier of a staking position.
                                    Only required for Babylon staking at the
                                    moment (documentation will come soon).
                              required:
                                - mode
                                - senderPubKey
                                - validatorAddress
                                - stakeId
                              title: Withdraw Unlocked Funds
                              description: >-
                                Only supported for Babylon staking at the moment
                                (documentation will come soon).
                            - type: object
                              properties:
                                mode:
                                  type: string
                                  const: registerStake
                                senderPubKey:
                                  type: string
                                  description: >-
                                    Public key of the sender account, required
                                    in some situations. It is advised to provide
                                    it by default if you can.
                                senderForeignPubKey:
                                  type: string
                                  description: Staker's pubkey on the foreign chain. (hex)
                                senderAddress:
                                  type: string
                                  description: Address or ID of the sender account.
                                proofOfPossession:
                                  type: string
                                  description: >-
                                    staker's address on this chain, signed with
                                    the foreign chain's signer. (hex)
                                amount:
                                  type: string
                                  description: Staked amount on the foreign chain.
                                validatorPubKey:
                                  type: string
                                  description: >-
                                    Validator's pubkey on the foreign chain.
                                    (hex)
                                unsignedUnbondingTransaction:
                                  type: string
                                  description: >-
                                    Unsigned unbonding transaction on the
                                    foreign chain (as provided in the response
                                    of the encode request for the stake
                                    transaction).
                                signedStakingTransaction:
                                  type: string
                                  description: >-
                                    Signed staking transaction on the foreign
                                    chain (hex).
                                signedSlashingTransaction:
                                  type: string
                                  description: >-
                                    Signed slashing transaction on the foreign
                                    chain (hex).
                                signedUnbondingSlashingTransaction:
                                  type: string
                                  description: >-
                                    Signed unbonding slashing transaction on the
                                    foreign chain (hex).
                              required:
                                - mode
                                - senderPubKey
                                - senderForeignPubKey
                                - senderAddress
                                - proofOfPossession
                                - amount
                                - validatorPubKey
                                - unsignedUnbondingTransaction
                                - signedStakingTransaction
                                - signedSlashingTransaction
                                - signedUnbondingSlashingTransaction
                              title: Register Stake
                              description: >-
                                Only supported for Babylon staking at the moment
                                (documentation will come soon).
                  required:
                    - data
              required:
                - transaction
      responses:
        '200':
          description: >-
            Returns the transaction data encoded into a blockchain-specific
            format, ready for broadcasting.
          content:
            application/json:
              schema:
                type: object
                properties:
                  chainId:
                    type: string
                    enum:
                      - algorand
                      - cosmoshub
                      - cosmoshub-testnet
                      - osmosis
                      - osmosis-testnet
                      - celestia
                      - celestia-testnet
                      - dydx
                      - axelar
                      - ethereum
                      - sepolia
                      - holesky
                      - zksync
                      - zksync-sepolia
                      - injective-evm-testnet
                      - base
                      - base-sepolia
                      - optimism
                      - optimism-sepolia
                      - arbitrum
                      - arbitrum-sepolia
                      - bitcoin
                      - bitcoin-testnet
                      - bitcoin-signet
                      - polygon
                      - polygon-amoy
                      - bsc
                      - bsc-testnet
                      - linea
                      - linea-sepolia
                      - avalanche
                      - avalanche-fuji
                      - gnosis
                      - gnosis-chiado
                      - moonbeam
                      - moonriver
                      - moonbase
                      - fantom
                      - mantle
                      - litecoin
                      - dogecoin
                      - ton
                      - chiliz
                      - chiliz-testnet
                      - injective
                      - akash
                      - band
                      - dymension
                      - kyve
                      - neutron
                      - terra2
                      - stargaze
                      - tron
                      - evmos
                      - irisnet
                      - juno
                      - lum-network
                      - omniflix
                      - sei
                      - medibloc
                      - passage
                      - quasar
                      - seda
                      - sommelier
                      - shentu
                      - stride
                      - chihuahua
                      - bitsong
                      - persistence
                      - comdex
                      - fetch-ai
                      - humans-ai
                      - ki
                      - likecoin
                      - mars-hub
                      - provenance
                      - quicksilver
                      - saga
                      - ux-chain
                      - kava
                      - starknet
                      - babylon
                      - babylon-testnet
                      - monad-testnet
                      - berachain
                      - berachain-artio
                      - cronos
                      - world-chain
                  transaction:
                    type: object
                    properties:
                      data:
                        allOf:
                          - type: object
                            properties:
                              fees:
                                type: string
                                description: Transaction fees computed by the API.
                              gas:
                                type: string
                                description: >-
                                  Transaction gas computed by the API, when
                                  relevant for the chain.
                              nonce:
                                type: string
                                description: >-
                                  Transaction sequence number, when relevant for
                                  the chain.
                              memo:
                                type: string
                                description: >-
                                  Optional free text field, that is supported
                                  for some chains.
                              format:
                                type: string
                                enum:
                                  - json
                                  - hex
                                description: >-
                                  Controls the format of the returned encoded
                                  transaction. DEPRECATED, will be reworked at
                                  some point.
                              params:
                                description: >-
                                  Some additional chain-specific context
                                  computed by the API. If provided by the encode
                                  endpoint, it must be provided back as-is to
                                  the broadcast endpoint.
                            required:
                              - fees
                          - oneOf:
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: deployAccount
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  contractType:
                                    type: string
                                    enum:
                                      - argentx
                                    description: >-
                                      Provider of the account contract. Only
                                      ArgentX is supported at the moment.
                                required:
                                  - mode
                                  - senderPubKey
                                  - contractType
                                title: Deploy Account
                                description: Deploy a smart contract wallet account
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: transfer
                                  senderAddress:
                                    type: string
                                    description: Address or ID of the sender account.
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  recipientAddress:
                                    type: string
                                    description: Address or ID of the recipient account.
                                  amount:
                                    type: string
                                    description: >-
                                      Amount to use, either provided or computed
                                      by the API
                                  useMaxAmount:
                                    type: boolean
                                    description: >-
                                      Option to let the API compute the amount
                                      to use all available funds. Either use
                                      this or provide amount.
                                required:
                                  - mode
                                  - senderAddress
                                  - recipientAddress
                                  - amount
                                  - useMaxAmount
                                title: Transfer
                                description: Transfer chain native coins
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: transferToken
                                  tokenId:
                                    type: string
                                    description: >-
                                      Unique ID of the token to transfer (e.g
                                      contract address for EVM chains)
                                  senderAddress:
                                    type: string
                                    description: Address or ID of the sender account.
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  recipientAddress:
                                    type: string
                                    description: Address or ID of the recipient account.
                                  amount:
                                    type: string
                                    description: >-
                                      Amount to use, either provided or computed
                                      by the API
                                  useMaxAmount:
                                    type: boolean
                                    description: >-
                                      Option to let the API compute the amount
                                      to use all available funds. Either use
                                      this or provide amount.
                                required:
                                  - mode
                                  - tokenId
                                  - senderAddress
                                  - recipientAddress
                                  - amount
                                  - useMaxAmount
                                title: Transfer Token
                                description: Transfer chain tokens
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: stake
                                  senderAddress:
                                    type: string
                                    description: Address or ID of the sender account.
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  sourceValidatorAddress:
                                    type: string
                                    description: >-
                                      Address or ID of a validator. Can be used
                                      to move staking funds from this validator,
                                      if supported by the chain.
                                  targetValidatorAddress:
                                    type: string
                                    description: Address or ID of a validator
                                  amount:
                                    type: string
                                    description: >-
                                      Amount to use, either provided or computed
                                      by the API
                                  useMaxAmount:
                                    type: boolean
                                    description: >-
                                      Option to let the API compute the amount
                                      to use all available funds. Either use
                                      this or provide amount.
                                required:
                                  - mode
                                  - senderAddress
                                  - targetValidatorAddress
                                  - amount
                                  - useMaxAmount
                                title: Stake
                                description: Put some funds at stake
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: unstake
                                  senderAddress:
                                    type: string
                                    description: Address or ID of the sender account.
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  validatorAddress:
                                    type: string
                                    description: Address or ID of a validator
                                  stakeId:
                                    type: string
                                    description: >-
                                      Unique identifier of a staking position.
                                      Only required for Babylon staking at the
                                      moment (documentation will come soon).
                                  amount:
                                    type: string
                                    description: >-
                                      Amount to use, either provided or computed
                                      by the API
                                  useMaxAmount:
                                    type: boolean
                                    description: >-
                                      Option to let the API compute the amount
                                      to use all available funds. Either use
                                      this or provide amount.
                                required:
                                  - mode
                                  - senderAddress
                                  - validatorAddress
                                  - amount
                                  - useMaxAmount
                                title: Unstake
                                description: Stop staking some funds
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: claimRewards
                                  senderAddress:
                                    type: string
                                    description: Address or ID of the sender account.
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  validatorAddress:
                                    type: string
                                    description: Address or ID of a validator
                                  stakeId:
                                    type: string
                                    description: >-
                                      Unique identifier of a staking position.
                                      Only required for Babylon staking at the
                                      moment (documentation will come soon).
                                  compound:
                                    type: boolean
                                    description: >-
                                      When available for the chain, controls
                                      whether staking rewards are cashed or
                                      added to the staked funds.
                                required:
                                  - mode
                                  - senderAddress
                                  - validatorAddress
                                  - compound
                                title: Claim Rewards
                                description: Retrieve rewards from staking
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: withdraw
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  validatorAddress:
                                    type: string
                                    description: Address or ID of a validator
                                  stakeId:
                                    type: string
                                    description: >-
                                      Unique identifier of a staking position.
                                      Only required for Babylon staking at the
                                      moment (documentation will come soon).
                                required:
                                  - mode
                                  - senderPubKey
                                  - validatorAddress
                                  - stakeId
                                title: Withdraw Unlocked Funds
                                description: >-
                                  Only supported for Babylon staking at the
                                  moment (documentation will come soon).
                              - type: object
                                properties:
                                  mode:
                                    type: string
                                    const: registerStake
                                  senderPubKey:
                                    type: string
                                    description: >-
                                      Public key of the sender account, required
                                      in some situations. It is advised to
                                      provide it by default if you can.
                                  senderForeignPubKey:
                                    type: string
                                    description: >-
                                      Staker's pubkey on the foreign chain.
                                      (hex)
                                  senderAddress:
                                    type: string
                                    description: Address or ID of the sender account.
                                  proofOfPossession:
                                    type: string
                                    description: >-
                                      staker's address on this chain, signed
                                      with the foreign chain's signer. (hex)
                                  amount:
                                    type: string
                                    description: Staked amount on the foreign chain.
                                  stakerPubKey:
                                    type: string
                                    description: >-
                                      Staker's pubkey on the foreign chain.
                                      (hex)
                                  validatorPubKey:
                                    type: string
                                    description: >-
                                      Validator's pubkey on the foreign chain.
                                      (hex)
                                  unsignedUnbondingTransaction:
                                    type: string
                                    description: >-
                                      Unsigned unbonding transaction on the
                                      foreign chain (as provided in the response
                                      of the encode request for the stake
                                      transaction).
                                  signedStakingTransaction:
                                    type: string
                                    description: >-
                                      Signed staking transaction on the foreign
                                      chain (hex).
                                  signedSlashingTransaction:
                                    type: string
                                    description: >-
                                      Signed slashing transaction on the foreign
                                      chain (hex).
                                  signedUnbondingSlashingTransaction:
                                    type: string
                                    description: >-
                                      Signed unbonding slashing transaction on
                                      the foreign chain (hex).
                                required:
                                  - mode
                                  - senderPubKey
                                  - senderForeignPubKey
                                  - senderAddress
                                  - proofOfPossession
                                  - amount
                                  - stakerPubKey
                                  - validatorPubKey
                                  - unsignedUnbondingTransaction
                                  - signedStakingTransaction
                                  - signedSlashingTransaction
                                  - signedUnbondingSlashingTransaction
                                title: Register Stake
                                description: >-
                                  Only supported for Babylon staking at the
                                  moment (documentation will come soon).
                      encoded:
                        type: string
                    required:
                      - data
                      - encoded
                  status:
                    type: object
                    properties:
                      errors:
                        type: array
                        items:
                          type: object
                          properties:
                            message:
                              type: string
                          required:
                            - message
                      warnings:
                        type: array
                        items:
                          type: object
                          properties:
                            message:
                              type: string
                          required:
                            - message
                    required:
                      - errors
                      - warnings
                required:
                  - chainId
                  - transaction
                  - status
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````