Execute an Intent

Once the intent is defined, you can execute it using the execute() function from the IntentBuilder. It takes your defined states (the initial and target outcomes) and manages the transaction details like gas and calldata generation behind the scenes.

// Define from and to states 
const from = new Asset({...});

const to = new Stake({...});

// Execute the intent
intentBuilder.execute(from, to, account)
    .then(() => console.log('Intent executed successfully.'))
    .catch((error) => console.error('Error executing intent:', error));

How Intent Execution Works:

  1. Structure the Intent: Define both the initial (from) and target (to) states of the operation.

  2. Format an userIntentOp: BalloonDogs takes the structured intent and automatically converts it into a userOp, which is a pseudo-transaction based on the ERC-4337 standard.

  3. Sign with Account: The intent (now a userIntentOp) must be signed by the user’s Account. In BalloonDogs, the Account is a unified wallet that spans multiple blockchains, ensuring non-custodial, secure asset control.

  4. Publish to Bundler: Once signed, the userOp is published to the relevant chain’s bundler, which manages the transaction on that specific blockchain.

When you call the execute() function, BalloonDogs takes care of gas optimization, calldata generation, and ensures the transaction is efficiently executed across multiple blockchains.

Fetch the Transaction Receipt

After executing the intent, you can retrieve the transaction receipt to view details such as the transaction hash:

const receipt = await intentBuilder.getReceipt(1, solvedHash);
const txHash = receipt.result.receipt.transactionHash;

console.log(`View your transaction on Etherscan: https://etherscan.io/tx/${txHash}`);

This method lets you track and verify your transactions across blockchains, providing full transparency for DeFi operations.

Last updated