π·Ether Vault
Simple and Secure Ether Storage
Design Ethos
The EtherVault is a small contract designed to do two things. The first, is to take deposits and store ether in the contract. The only other function it has is to deliver ether withdrawals by checking the message sender's key, and checking the Ledger for proper balances before dispersement. It does not properly store or resolve other tokens or NFTs.
Storage
// Locksmith verifies key-holdership.
ILocksmith public locksmith;
// The ledger enforces asset rights
ILedger public ledger;
// We hard-code the arn into the contract.
bytes32 public ethArn;
// keep track of full contract balance for invariant control
uint256 public etherBalance;The ethArn is defined in the initializer:
ethArn = AssetResourceName.AssetType({
contractAddress: AssetResourceName.GAS_TOKEN_CONTRACT,
tokenStandard: AssetResourceName.GAS_TOKEN_STANDARD,
id: AssetResourceName.GAS_ID}).arn();Operations
The EtherVault is a simple vault that mostly facilitates deposits and withdrawals.
deposit
The message sender will send ether to this method and claim a key with which they are claiming to use to deposit. The vault will check to ensure the message sender is in fact holding the key at the time of the call. It then registers the deposit for the key and asset (ETH/gas) based on the message value. The vault keeps track of the ether balance separately from address(this).balance to ensure to protect selfdestruct or other various means of having more in the contract than is tracked on the ledger.
withdrawal
There are a few ways the contract enables withdrawals.
Internally, both interfaces use _withdrawal. This method will only succeed if the key is held by the message sender, the key has permission to withdrawal the requested amount from the ledger.
Last updated