Skip to content

IntentBuilder

SIP Protocol API Reference v0.7.0


SIP Protocol API Reference / IntentBuilder

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:963

Fluent builder for creating shielded intents

Provides a chainable API for constructing intents step-by-step. More ergonomic than passing a large parameter object directly.

Builder Methods:

const intent = await new IntentBuilder()
.input('solana', 'SOL', 10n * 10n**9n)
.output('ethereum', 'ETH', 0n)
.privacy(PrivacyLevel.SHIELDED)
.build()
import { IntentBuilder, PrivacyLevel, MockProofProvider } from '@sip-protocol/sdk'
const builder = new IntentBuilder()
const intent = await builder
.input('near', 'NEAR', 100n * 10n**24n, wallet.address) // 100 NEAR
.output('zcash', 'ZEC', 95n * 10n**8n) // Min 95 ZEC
.privacy(PrivacyLevel.COMPLIANT)
.recipient('sip:zcash:0x02abc...123:0x03def...456')
.slippage(1) // 1%
.ttl(600) // 10 minutes
.withProvider(new MockProofProvider())
.build()
console.log('Intent created:', intent.intentId)
console.log('Has proofs:', !!intent.fundingProof && !!intent.validityProof)

new IntentBuilder(): IntentBuilder

IntentBuilder

input(chain, token, amount, sourceAddress?): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:976

Set the input for the intent

string

string

number | bigint

string

this

If chain or amount is invalid


output(chain, token, minAmount?): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:982

Set the output for the intent

string

string

number | bigint

this

If chain is invalid


privacy(level): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:988

Set the privacy level

PrivacyLevel

this

If privacy level is invalid


recipient(metaAddress): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:994

Set the recipient’s stealth meta-address

string

this

If stealth meta-address format is invalid


slippage(percent): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1001

Set slippage tolerance

number

Slippage percentage (e.g., 1 for 1%)

this

If slippage is out of range


ttl(seconds): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1007

Set time-to-live in seconds

number

this

If TTL is not a positive integer


withProvider(provider): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1024

Set the proof provider for automatic proof generation

ProofProvider

The proof provider to use

this

this for chaining

const intent = await builder
.input('near', 'NEAR', 100n)
.output('zcash', 'ZEC', 95n)
.privacy(PrivacyLevel.SHIELDED)
.withProvider(mockProvider)
.build()

withSignatures(signatures): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1049

Set the signatures and secret for proof generation

Required for production proof generation. Provides the cryptographic materials needed to generate valid ZK proofs.

Object containing ownership signature, sender secret, and authorization signature

Uint8Array

Uint8Array

Uint8Array

this

this for chaining

const intent = await builder
.input('near', 'NEAR', 100n)
.output('zcash', 'ZEC', 95n)
.privacy(PrivacyLevel.SHIELDED)
.withProvider(noirProvider)
.withSignatures({
ownershipSignature: await wallet.signMessage(address),
senderSecret: wallet.privateKey,
authorizationSignature: await wallet.signMessage(intentHash),
})
.build()

withPlaceholders(allow?): this

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1063

Allow placeholder signatures for development/testing

WARNING: Never use this in production! Proofs with placeholders are not cryptographically valid.

boolean

Whether to allow placeholders (default: true)

this

this for chaining


build(): Promise<ShieldedIntent>

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1072

Build the shielded intent

If a proof provider is set and the privacy level requires proofs, they will be generated automatically.

Promise<ShieldedIntent>

Promise resolving to the shielded intent