Overview
Fuel deposits use a script-based transaction model. The Layerswap API returns a pre-built script transaction incall_data that you need to deserialize, fund with the required coin quantities, and submit.
Prerequisites:
- fuels (Fuel TypeScript SDK) for transaction construction and wallet interaction
call_data Format
For Fuel,call_data is a JSON string containing two fields:
script— A serializedScriptTransactionRequestobject containing the transaction script, inputs, outputs, and other parameters.quantities— An array of coin quantities required to fund the transaction (covers the transfer amount and fees).
Transaction Construction
Reconstruct the ScriptTransactionRequest
Use
ScriptTransactionRequest.from() to create a proper transaction request object from the serialized data.Estimate and fund
Call
estimateAndFund() on the transaction with the wallet and required quantities. This estimates gas costs and adds the necessary coin inputs.Simulate (optional)
Simulate the transaction against the Fuel provider to verify it will succeed before sending.
Full Example (Server-side with Private Key)
Full Example (Browser with Fuel Wallet)
When using the Fuel Wallet browser extension, access the wallet through the Fuel connector:Using @fuels/react Hooks
If you use the Fuel React SDK, you can integrate with theuseFuel hook: