Kiln docs
Search
K

ETH Batch Deposit Contract

The Kiln Ethereum Batch Deposit Contract is a minimal implementation of deposit transaction batching. The goal is to deposit N validations keys in one transaction with N * 32 ETH as value.

Contract instances

The Batch Deposit Contract is available at:

Batch Deposit

You can interact with the batchDeposit function of the contract to deposit multiple validator keys deposit data, with the multiple of 32 ETH as transaction value.
We recommend you use it to send N deposit data with N * 32 ETH where N < 150.
function batchDeposit(
bytes[] calldata pubkeys,
bytes[] calldata withdrawal_credentials,
bytes[] calldata signatures,
bytes32[] calldata deposit_data_roots
) external payable
ABI:
{
"inputs": [
{
"internalType": "bytes[]",
"name": "pubkeys",
"type": "bytes[]"
},
{
"internalType": "bytes[]",
"name": "withdrawal_credentials",
"type": "bytes[]"
},
{
"internalType": "bytes[]",
"name": "signatures",
"type": "bytes[]"
},
{
"internalType": "bytes32[]",
"name": "deposit_data_roots",
"type": "bytes32[]"
}
],
"name": "batchDeposit",
"outputs": [],
"stateMutability": "payable",
"type": "function",
"payable": true
}

Source Files

The smart contract is relatively straightforward and does not maintain a state of the deposited keys. It simply exposes a function batchDeposit(bytes[] calldata pubkeys,bytes[] calldata withdrawal_credentials, bytes[] calldata signatures, bytes32[] calldata deposit_data_roots) external payable one can call with N deposit data and N *32 ETH as tx value.
The Contract sources are available here:

Performance

Here is a model of gas costs evolution based on a mainnet fork:
Batch Deposit 7
Gas: 221233
Batch Deposit 8
Gas: 251485
Batch Deposit 9
Gas: 279802
Batch Deposit 10
Gas: 312046
Batch Deposit 100
Gas: 3049083
Batch Deposit 200
Gas: 6103163
Batch Deposit 300
Gas: 9233661
Batch Deposit 400
Gas: 12419018
Batch Deposit 500
Gas: 15697211
We recommend to not batch deposit more than 150 keys to avoid transaction with too much gas and low chance to get included by the network.

Security

Batch Deposit Contract is based on Stake Fish batch deposit contract which has been audited. Some of Kiln partners have also internally audited the Batch Deposit Contract.

FAQs

What is the interaction between the Kiln "batch deposit" contract and the ETH staking contract?
The official Beacon chain deposit contract requires sending 32 ETH + the parameters to stake: pubkeys, withdrawal credentials, signatures and deposit_data_roots. This official contract requires 1 transaction per deposit, so to stake n validators requires doing n transactions. The Kiln batch deposit contract receives n*32 ETH and an array of length n of the staking parameters for deposits (the same parameters as the official contrat: pubkeys, withdrawal credentials, signatures and deposit_data_roots).
What it then does is perform n deposits on the official deposit contract with 32 ETH each atomically within the same transaction, thus saving a significant amount of gas compared to the standard approach.
Please note:
  1. 1.
    The batch deposit contract never holds any funds
  2. 2.
    if a number different than a multiple of 32 ETH is sent or there are not enough parameters to cover it'll return the ETH back to the user
Is there a "transfer" of funds between the two contracts?
Every time a batch is sent to the deposit contract this contract does internal transactions to send these funds to the Beacon chain contract. All this is done in the same transaction, atomically, and in the same block so it never holds any funds. See the previous answer for more details.
Do the staking rewards ever "pass through" the Kiln batch deposit contract?
Never, it's just for depositing the 32 ETH + the parameters in one call to the official contract. Once this is done the rewards go directly to the withdrawal credentials of the validator (your end-user wallet).
Are there any "private" functions of the batch deposit contract that only Kiln can alter or owns?
No, there are no private functions. The contract is not upgradeable so it cannot be altered. The only callable function is batchDeposit. The full source code is published above.