View Source Hyperliquid.Api.Exchange.ApproveAgent (hyperliquid v0.2.2)

Approve an agent to trade on behalf of your account.

Agents are sub-keys that can be granted trading permissions without exposing your main private key.

See: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint

Summary

Functions

Approve an agent to trade on your behalf.

Types

@type approve_opts() :: [
  agent_name: String.t(),
  private_key: String.t(),
  expected_address: String.t()
]
@type approve_response() :: %{status: String.t(), response: map()}

Functions

Link to this function

approve(agent_address, opts \\ [])

View Source
@spec approve(String.t(), approve_opts()) ::
  {:ok, approve_response()} | {:error, term()}

Approve an agent to trade on your behalf.

Parameters

  • agent_address: Address of the agent to approve (0x...)
  • opts: Optional parameters

Options

  • :private_key - Private key for signing (falls back to config)
  • :expected_address - When provided, validates the private key derives to this address
  • :agent_name - Human-readable name for the agent

Returns

  • {:ok, response} - Approval result
  • {:error, term()} - Error details

Examples

# Approve agent with default name
{:ok, result} = ApproveAgent.approve("0x1234...")

# Approve agent with custom name
{:ok, result} = ApproveAgent.approve("0x1234...", agent_name: "Trading Bot")

Breaking Change (v0.2.0)

private_key was previously the first positional argument. It is now an option in the opts keyword list (:private_key).