Depositing Assets
Deposit assets from Ethereum to Aztec.
Deposits on Aztec have 2 steps:
- The user sends a transaction specifying an amount of ETH or DAI to deposit to the Aztec rollup contract by calling
depositPendingFunds
. When deposit DAI with this function, the rollup processor must be approved to spend the user's DAI. Or a user sends a transaction with DAI to the rollup contract by callingdepositPendingFundsPermitNonStandard
. Read more about using the DAI permit flow here. - The user creates a proof on Aztec to claim the pending deposit. The proof includes information about the Ethereum account that made the deposit, the amount of the deposit, the Aztec transaction fee and the recipient account on the Aztec network.
When using an externally owned account on Ethereum, this flow is managed by the SDK. You can read more about using the SDK to deposit funds into Aztec on the SDK deposit page.
If the depositing account is a smart contract (e.g. a smart contract wallet), a proof hash corresponding to the hash generated by the DepositController must be passed to depositPendingFunds
(or similar). For more detail about how to execute deposits from a smart contract, refer to the Advanced Usage section of the SDK page on deposits.
Here is the interface for depositPendingFunds
.
function depositPendingFunds(
uint256 assetId,
uint256 amount,
address owner,
bytes32 proofHash
) external payable;
Input | Description |
---|---|
assetId | The asset id of the asset being deposited. ETH is asset id 0, DAI is asset id 1. |
amount | The amount of the asset being deposited. |
owner | The Ethereum address that can spend the deposited funds. This is used in the proof generation in step 2 mentioned above. |
proofHash | The 32 byte transaction id that can spend the deposited funds. This is intended to be used when the depositor is a smart contract (e.g. a multisig wallet) that cannot sign data. |
depositPendingFundsPermitNonStandard
works similarly to depositPendingFunds
but with the permit flow instead of the approve flow. DAI requires a non-standard flow because their implementation of permit requires a nonce.