Overview
The build transaction endpoint constructs a Solana transaction from an Anchor IDL instruction definition. It handles argument encoding, account validation, and transaction serialization.Endpoint
Request Body
Map of account names to public keys (base58 format)
Map of argument names to values. Types are automatically encoded based on the IDL.Supported types:
- Primitives:
u8,u16,u32,u64,u128,i8,i16,i32,i64,i128,f32,f64,bool - Complex:
string,publicKey,bytes - Collections:
Vec<T>,[T; N](fixed-size arrays) - Optional:
Option<T> - Custom: Defined structs from IDL types
Public key (base58) of the transaction fee payer
Optional recent blockhash. If not provided, it will be fetched from the RPC.
Network to use for RPC calls:
"mainnet"or"mainnet-beta"- Solana mainnet"devnet"- Solana devnet- Custom RPC URL (e.g.,
"https://api.custom-rpc.com")
Response
Base58-encoded serialized transaction message
Human-readable description of the transaction
List of accounts used in the instruction
Detailed instruction information
Estimated transaction fee in lamports (typically 5000)
Example
Response Example
Error Responses
400 Bad Request
- Missing required fields (
accounts,args, orfeePayer) - Invalid build request (missing required accounts/arguments)
- Invalid public key format
404 Not Found
- Project not found or not public
- Instruction not found in IDL
500 Internal Server Error
- Failed to build transaction
- RPC connection error
Validation
The endpoint performs the following validations:-
Account Validation
- All required accounts must be provided
- Public keys must be valid base58 (32-44 characters)
- Unknown account names are rejected
-
Argument Validation
- All required arguments must be provided
- For defined types (structs), all fields must be present
- Type validation based on IDL definitions
-
Transaction Building
- Instruction discriminator: SHA-256 hash of
"global:<instruction_name>"(first 8 bytes) - Arguments encoded using Borsh serialization
- Recent blockhash fetched if not provided
- Instruction discriminator: SHA-256 hash of
Rate Limiting
This endpoint is rate-limited to prevent abuse. See Rate Limiting for details.Related Endpoints
- List Instructions - Get available instructions
- Get Instruction Details - View instruction schema
- Derive PDA - Calculate Program Derived Addresses