Skip to main content

IntentBuilder

The IntentBuilder provides a fluent, chainable API for constructing buy-side AcquisitionIntent objects.

Examples

const intent = new IntentBuilder('ar://intent-123')
.fromBuyer('0xBuyer...')
.forTarget('asset-123')
.desiringAction('TRANSFER')
.withAcceptableDuty('PAYMENT', { type: 'PAYMENT_AMOUNT_GTE', value: { amount: '90.00', currency: 'USDC' }})
.withAcceptableDuty('PAYMENT', { type: 'PAYMENT_AMOUNT_LTE', value: { amount: '95.00', currency: 'USDC' }})
.build();

Definition

class IntentBuilder {
constructor(intentURI: string);
fromBuyer(buyer: string): this;
forTarget(target: string): this;
desiringAction(action: string): this;
withExpiration(isoTimestamp: string): this;
withAcceptableDuty(dutyType: string, constraint: IntentConstraint): this;
build(): AcquisitionIntent;
}

Constructor

Creates a new IntentBuilder instance.

Parameters:

  • intentURI (string) - A unique, persistent URI identifying this specific intent.

Methods

fromBuyer

Sets the identifier of the buyer.

fromBuyer(buyer: string): this

Parameters:

  • buyer (string)

forTarget

Sets the target asset the buyer desires.

forTarget(target: string): this

Parameters:

  • target (string)

desiringAction

Sets the action the buyer desires permission for.

desiringAction(action: string): this

Parameters:

  • action (string)

withExpiration

Sets an optional expiration timestamp for the intent.

withExpiration(isoTimestamp: string): this

Parameters:

  • isoTimestamp (string)

withAcceptableDuty

Adds a constraint for an acceptable duty. This is the core of defining the buy-side offer's flexibility.

withAcceptableDuty(dutyType: string, constraint: IntentConstraint): this

Parameters:

  • dutyType (string) - The type of duty (e.g., 'PAYMENT').
  • constraint (IntentConstraint) - The IntentConstraint defining the acceptable range.

build

Finalizes and returns the constructed AcquisitionIntent object. Throws an error if the intent is structurally incomplete.

build(): AcquisitionIntent