import {
encodeIntent,
hashIntent,
intentVaultAddress,
Intent
} from './utils/intent'
import { encodeTransfer } from './utils/encode'
// 1. Create the intent
const intent: Intent = {
destination: 137, // Polygon
route: {
salt: '0x' + '1'.repeat(64),
deadline: Math.floor(Date.now() / 1000) + 3600,
portal: '0xPolygonPortal...',
nativeAmount: 0n,
tokens: [
{
token: '0xUSDC...',
amount: 1000000n // 1 USDC
}
],
calls: [
{
target: '0xUSDC...',
data: await encodeTransfer('0xRecipient...', 1000000),
value: 0
}
]
},
reward: {
deadline: Math.floor(Date.now() / 1000) + 7200,
creator: '0xYourAddress...',
prover: '0xProverAddress...',
nativeAmount: 100000000000000000n, // 0.1 ETH
tokens: []
}
}
// 2. Hash the intent
const { routeHash, rewardHash, intentHash } = hashIntent(intent)
console.log('Intent hash:', intentHash)
// 3. Predict vault address
const vaultAddr = await intentVaultAddress(
'0xIntentSource...',
intent
)
console.log('Vault address:', vaultAddr)
// 4. Encode for on-chain submission
const encodedIntent = encodeIntent(intent)
console.log('Encoded intent:', encodedIntent)