unionlabs/union · error · Error
Invalid Aptos transport
Error message
Invalid Aptos transport
What it means
getAptosClient with authAccess "key" requires parameters.transport to be a viem-style transport function: it is invoked as transport({}) and the client reads .value?.url for the RPC endpoint. Anything that is not a function — a raw URL string, a plain object, undefined — fails the typeof check and throws 'Invalid Aptos transport'. A parallel check then requires transport({}).value?.url to be non-empty.
Source
Thrown at typescript-sdk/src/aptos/client.ts:56
* Overloads for retrieving an Aptos client.
*/
async function getAptosClient(
parameters: AptosClientParameters & { authAccess: "key" },
): Promise<{ authAccess: "key"; aptos: Aptos; signer: AptosAccount }>
// async function getAptosClient(
// parameters: AptosClientParameters & { authAccess: "wallet" }
// ): Promise<{ authAccess: "wallet"; aptos: Aptos; signer: AptosBrowserWallet }>
async function getAptosClient(
parameters: AptosClientParameters & { authAccess: AuthAccess },
): Promise<
| { authAccess: "key"; aptos: Aptos; signer: AptosAccount }
| { authAccess: "wallet"; aptos: Aptos; signer: AptosBrowserWallet }
> {
if (parameters.authAccess === "key") {
if (typeof parameters.transport !== "function") {
throw new Error("Invalid Aptos transport")
}
const rpcUrl = parameters.transport({}).value?.url
if (!rpcUrl) {
throw new Error("No Aptos RPC URL found")
}
const config = new AptosConfig({
fullnode: rpcUrl,
network: Network.CUSTOM,
})
return {
authAccess: "key",
aptos: new Aptos(config),
signer: parameters.account as AptosAccount,
}
}
if (parameters.authAccess === "wallet") {
if (typeof parameters.transport !== "object") {View on GitHub (pinned to 031785bb6d)
Solutions
- Wrap the URL in a transport: import { http } from "viem" and pass transport: http("https://fullnode.testnet.aptoslabs.com/v1")
- For custom transports, make them return { value: { url } } so the client can extract the endpoint
- Confirm authAccess: "key" is intended — the wallet flow does not hit this check
Example fix
// before
const client = createUnionClient({
chainId: union.testnet.cosmosChainId,
transport: "https://fullnode.testnet.aptoslabs.com/v1", // string!
})
// after
import { http } from "viem"
const client = createUnionClient({
chainId: union.testnet.cosmosChainId,
transport: http("https://fullnode.testnet.aptoslabs.com/v1"),
}) Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof parameters.transport !== "function") {
throw new Error("transport must be a Transport function, e.g. http(rpcUrl)")
} Type guard
import type { Transport } from "viem"
const isTransport = (t: unknown): t is Transport => typeof t === "function" Try / catch
try {
const client = await getAptosClient({ authAccess: "key", transport })
} catch (e) {
if (e instanceof Error && e.message === "Invalid Aptos transport") {
throw new Error("Pass a viem Transport: http('https://…/v1'), not a URL string")
}
throw e
} Prevention
- Always wrap RPC URLs with viem's http() before passing them as transport
- For custom transports, return { value: { url } } so the client can extract the endpoint
- Type the client options as Transport at the call boundary to catch strings at compile time
When it happens
Trigger: Calling createUnionClient with a string RPC URL instead of http(url); passing a config object as transport; a custom/test-double transport whose return value has no .value.url; omitting transport entirely.
Common situations: Habit of passing URLs directly (common with raw fetch or other SDKs); custom transports built for mocking in tests that don't follow the viem Transport shape.
Related errors
- No Aptos RPC URL found
- no `signer` passed
- Invalid Sui signer: expected Ed25519Keypair
- waiting for transaction failed
- simulation result not found
AI-assisted analysis of unionlabs/union@031785bb6d (2026-08-16).
Data as JSON: /api/errors/36d4ee81782b2424.
Report an issue: GitHub.