Whether all required tokens have been selected
Token allowances for the deployment
Callback executed successfully or no callback registered
Add order transaction calldata
Owner wallet address
Approval transaction calldatas or NoDeposits
Combined deposit and add order multicall calldata
Deposit transaction calldatas or NoDeposits
Builder state instance for metadata embedding
Exports the current configuration as a complete dotrain text file.
This generates a valid dotrain file with YAML frontmatter and Rainlang code, preserving all configurations and bindings. Useful for saving or sharing orders.
The output follows the standard dotrain format:
builder:
...
---
#binding1 !The binding value
#calculate-io
...
const result = builder.generateDotrainText();
if (result.error) {
console.error("Export failed:", result.error.readableMsg);
return;
}
const dotrain = result.value;
// Do something with the dotrain
Complete dotrain content with YAML frontmatter separator
Token contract address
Account address to check balance for
Token balance for the specified account
Complete builder configuration for all fields, deposits, and I/O
Optionalfilter_defaults: null | booleanOptional filter: true for fields with defaults, false for fields without defaults, undefined for all
Filtered field definitions
Array of all configured field values
Gets information for all tokens used in the current deployment's order.
This function automatically determines which tokens to fetch based on the deployment:
select-tokens is defined, returns info for those tokensThis may trigger multiple blockchain queries if token data isn't cached in YAML. Consider caching the results in your application.
const result = await builder.getAllTokenInfos();
if (result.error) {
console.error("Error:", result.error.readableMsg);
return;
}
const tokens = result.value;
// Do something with the tokens
Array of complete token information
Optionalsearch: null | stringOptional search string to filter tokens
Array of token information for the deployment's network
Retrieves the complete builder configuration including all deployments.
This returns the parsed builder section from the YAML, filtered to include only the current deployment. Use this to access order-level metadata.
const result = builder.getBuilderConfig();
if (result.error) {
console.error("Config error:", result.error.readableMsg);
return;
}
const config = result.value;
// Do something with the config
Complete builder configuration with name, description, and deployments
Composes the final Rainlang code with all bindings and scenarios applied.
This method updates scenario bindings from current field values and composes the Rainlang code ready to be displayed on the UI.
Updates the internal scenario bindings before composition.
const result = await builder.getComposedRainlang();
if (result.error) {
console.error("Composition error:", result.error.readableMsg);
return;
}
const rainlang = result.value;
// Do something with the rainlang
Composed Rainlang code with comments for each entrypoint
Gets the active deployment's configuration including fields, deposits, and tokens.
This is the primary method for accessing deployment-specific settings that define what inputs are needed from the user. The configuration drives UI generation.
fields - Input fields requiring user configurationdeposits - Token deposits with amounts and presetsselectTokens - Tokens that users must choose addresses fordeployment - Underlying order and scenario configurationconst result = builder.getCurrentDeployment();
if (result.error) {
console.error("Error:", result.error.readableMsg);
return;
}
const deployment = result.value;
// Do something with the deployment
Active deployment with all configuration details
Gets metadata for the currently active deployment.
Instance method that returns name and description for the deployment selected during initialization.
const result = builder.getCurrentDeploymentDetails();
if (result.error) {
console.error("Error:", result.error.readableMsg);
return;
}
const details = result.value;
// Do something with the details
Current deployment's metadata
Owner wallet address
Complete deployment transaction arguments
Token key to get presets for
Array of preset deposit amounts
Array of configured deposits with token info and amounts
Field binding identifier to look up
Complete field configuration
Field identifier from the YAML configuration
Field value with the identifier, value, and preset flag
Array of token keys that need deposits
Array of field definitions that need to be set
Array of token selection configurations
Retrieves detailed token information from YAML configuration or blockchain.
This function first checks the YAML for cached token data (decimals, name, symbol). If any information is missing, it queries the blockchain to fetch the complete details. This hybrid approach minimizes RPC calls while ensuring accurate data.
The RPC endpoint is determined by the deployment's order network configuration.
// Get token info (may query blockchain)
const result = await builder.getTokenInfo("weth");
if (result.error) {
console.error("Token error:", result.error.readableMsg);
return;
}
const tokenInfo = result.value;
// Do something with the tokenInfo
Token identifier from the YAML tokens section
Complete token details including address, decimals, name, symbol, and chain_id
Map of input/output vault IDs by token
Whether any deposit has been set
Whether any vault ID has been set
Token key to check
Whether the token has been selected
Base64-encoded compressed serialized state
Token key from the YAML configuration
Deposit amount as a decimal string
Field identifier from the YAML configuration
Value to save (can be a preset value or custom input)
Array of field-value pairs to save
Token key from select-tokens configuration
Token contract address as hex string
Vault type (input or output)
Token key
Optionalvault_id: null | stringOptional vault ID as hex string
Token key to remove deposit for
Field identifier from the YAML configuration
Token key to deselect
StaticcomputeComplete dotrain YAML content
Optionalsettings: null | string[]Optional additional YAML settings
Base64-encoded SHA256 hash of the dotrain content
StaticgetGets metadata for a specific deployment by key.
Convenience method that extracts details for a single deployment without parsing all deployments.
const result = await getDeploymentDetail(dotrainYaml, "mainnet-order");
if (result.error) {
console.error("Not found:", result.error.readableMsg);
return;
}
const detail = result.value;
// Do something with the detail
Complete dotrain YAML content
Optional additional YAML configuration strings to merge with the frontmatter
Deployment identifier to look up
Deployment name and description
StaticgetGets metadata for all deployments defined in the configuration.
This static method extracts name and description for each deployment, useful for building deployment selection interfaces with rich descriptions.
const result = await getDeploymentDetails(dotrainYaml);
if (result.error) {
console.error("Error:", result.error.readableMsg);
return;
}
// key is the deployment key
// value is the deployment metadata
for (const [key, value] of result.value) {
const {
// name is the deployment name
// description is the deployment description
name,
description,
// short_description is the deployment short description (optional)
short_description,
} = value;
}
Complete dotrain YAML content
Optionalsettings: null | string[]Optional additional YAML configuration strings to merge with the frontmatter
Map of deployment key to metadata
StaticgetLists all available builder deployment keys from a dotrain YAML file.
This function parses the builder section of the YAML frontmatter to extract deployment keys that can be used to initialize a builder instance. Use this to build deployment selectors in your UI.
const dotrain = `
builder:
deployments:
mainnet-order:
name: "Mainnet Trading"
testnet-order:
name: "Test order"
`;
const result = await RaindexOrderBuilder.getDeploymentKeys(dotrain);
if (result.error) {
console.error("Error:", result.error.readableMsg);
return;
}
const deploymentKeys = result.value;
// Do something with the deploymentKeys
Complete dotrain YAML content including the builder.deployments section
Optionalsettings: null | string[]Optional additional YAML configuration strings to merge with the frontmatter
Array of deployment identifiers (keys from the deployments map)
StaticgetExtracts order-level metadata from a dotrain configuration.
This static method allows checking order details without creating a builder instance, useful for displaying order information before deployment selection.
The YAML must contain:
builder.name - Order display namebuilder.description - Full order descriptionbuilder.short-description - Brief summary (optional but recommended)const result = await getOrderDetails(dotrainYaml);
if (result.error) {
console.error("Error:", result.error.readableMsg);
return;
}
const details = result.value;
// Do something with the details
Complete dotrain YAML content
Optionalsettings: null | string[]Optional additional YAML configuration strings to merge with the frontmatter
Order name, description, and optional short description
StaticnewComplete dotrain YAML content
Optional additional YAML settings
Serialized state string from serializeState
Optionalstate_update_callback: null | FunctionOptional state update callback function
Restored builder instance
StaticnewCreates a new builder instance for managing a specific deployment configuration.
This is the primary initialization function that sets up the builder context for a chosen deployment. The instance tracks field values, deposits, token selections, and provides methods for generating order transactions.
The callback function receives a serialized state string on every change, enabling auto-save functionality or state synchronization across components.
// Basic initialization
const result = await RaindexOrderBuilder.newWithDeployment(dotrainYaml, "mainnet-order");
if (result.error) {
console.error("Init failed:", result.error.readableMsg);
return;
}
const builder = result.value;
// With state persistence
const result = await RaindexOrderBuilder.newWithDeployment(
dotrainYaml,
"mainnet-order",
(serializedState) => {
localStorage.setItem('orderState', serializedState);
}
);
if (!result.error) {
const builder = result.value;
// Use builder instance...
}
Complete dotrain YAML content with all configurations
Optional additional YAML configuration strings to merge with the frontmatter
Key of the deployment to activate (must exist in YAML)
Optionalstate_update_callback: null | FunctionOptional function called on state changes. After a state change (deposit, field value, vault id, select token, etc.), the callback is called with the new state. This is useful for auto-saving the state of the builder across sessions.
Initialized builder instance for further operations
Owner wallet address