IntentBuilder
SIP Protocol API Reference v0.7.0
SIP Protocol API Reference / IntentBuilder
Class: IntentBuilder
Section titled “Class: 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:
- input: Set input asset and amount
- output: Set output asset and constraints
- privacy: Set privacy level
- recipient: Set recipient stealth meta-address
- slippage: Set slippage tolerance
- ttl: Set time-to-live
- withProvider: Set proof provider
- build: Create the intent
Examples
Section titled “Examples”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)- createShieldedIntent for the underlying implementation
- CreateIntentParams for parameter types
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new IntentBuilder():
IntentBuilder
Returns
Section titled “Returns”IntentBuilder
Methods
Section titled “Methods”input()
Section titled “input()”input(
chain,token,amount,sourceAddress?):this
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:976
Set the input for the intent
Parameters
Section titled “Parameters”string
string
amount
Section titled “amount”number | bigint
sourceAddress?
Section titled “sourceAddress?”string
Returns
Section titled “Returns”this
Throws
Section titled “Throws”If chain or amount is invalid
output()
Section titled “output()”output(
chain,token,minAmount?):this
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:982
Set the output for the intent
Parameters
Section titled “Parameters”string
string
minAmount?
Section titled “minAmount?”number | bigint
Returns
Section titled “Returns”this
Throws
Section titled “Throws”If chain is invalid
privacy()
Section titled “privacy()”privacy(
level):this
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:988
Set the privacy level
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
Throws
Section titled “Throws”If privacy level is invalid
recipient()
Section titled “recipient()”recipient(
metaAddress):this
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:994
Set the recipient’s stealth meta-address
Parameters
Section titled “Parameters”metaAddress
Section titled “metaAddress”string
Returns
Section titled “Returns”this
Throws
Section titled “Throws”If stealth meta-address format is invalid
slippage()
Section titled “slippage()”slippage(
percent):this
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1001
Set slippage tolerance
Parameters
Section titled “Parameters”percent
Section titled “percent”number
Slippage percentage (e.g., 1 for 1%)
Returns
Section titled “Returns”this
Throws
Section titled “Throws”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
Parameters
Section titled “Parameters”seconds
Section titled “seconds”number
Returns
Section titled “Returns”this
Throws
Section titled “Throws”If TTL is not a positive integer
withProvider()
Section titled “withProvider()”withProvider(
provider):this
Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:1024
Set the proof provider for automatic proof generation
Parameters
Section titled “Parameters”provider
Section titled “provider”The proof provider to use
Returns
Section titled “Returns”this
this for chaining
Example
Section titled “Example”const intent = await builder .input('near', 'NEAR', 100n) .output('zcash', 'ZEC', 95n) .privacy(PrivacyLevel.SHIELDED) .withProvider(mockProvider) .build()withSignatures()
Section titled “withSignatures()”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.
Parameters
Section titled “Parameters”signatures
Section titled “signatures”Object containing ownership signature, sender secret, and authorization signature
ownershipSignature
Section titled “ownershipSignature”Uint8Array
senderSecret
Section titled “senderSecret”Uint8Array
authorizationSignature
Section titled “authorizationSignature”Uint8Array
Returns
Section titled “Returns”this
this for chaining
Example
Section titled “Example”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()
Section titled “withPlaceholders()”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.
Parameters
Section titled “Parameters”allow?
Section titled “allow?”boolean
Whether to allow placeholders (default: true)
Returns
Section titled “Returns”this
this for chaining
build()
Section titled “build()”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.
Returns
Section titled “Returns”Promise<ShieldedIntent>
Promise resolving to the shielded intent