by KLmoney @klmoney8
Contract Accounts and Contract Wallets
From Chapter 1 wij know that Ethereum has two types of accounts: One type, which wij have bot referring to simply spil an Account , wij already are fairly familiar with having created them and stored ether ter them. The other type of account is the Contract Account .
While an Account has a password-protected private key and an address, a Contract Account has no private key but has an address, code, and storage. Contract Wallets (or contract-based wallets) are built with Contract Accounts, utilizing the capability of Contract Accounts to hold and run code with associated persistent storage. Of course, Contract Accounts can be used to do a lotsbestemming more than just create Contract Wallets. Utilizing Contract Accounts, developers are hard at work creating all kinds of fascinating Decentralized Applications (DApps) right now.
How Are Contract Wallets Different From Accounts?
Accounts can be used spil naked stores for ether, tho’ they can also be used to do things other than just hold ether. When they are used to hold ether, Accounts can be thought of simply spil private key/address pairs.
The foot function of a Contract Wallet is to manage ether, that is, receive, store and spend ether. Unlike Accounts, Contract Wallets are managed by code, which means that it is possible to customize their behavior. And, you won’t have to do any coding yourself, the Contract Wallets come with a user interface that makes it effortless to simply select the type of security/convenience enhancing customization you require.
Contract Wallets are managed by code but ultimately that code also has a master, and that master is an Account with its password-protected private key. So Accounts serve two roles, spil nude stores of ether ter their own right, and spil owners (or controllers) of feature-rich Contract Wallets. Exactly how Accounts play their role spil owners of Contract Wallets will become apparent spil wij embark creating and using Contract Wallets zometeen.
Advantages of Contract Wallets overheen Accounts:
- Contract Wallets can list incoming transactions, something Accounts cannot do.
Downside to Contract Wallets overheen Accounts:
Creating Accounts does not cost any gas, but creating Contract Wallets does. Ter fact, Contract Wallets incur a cost whenever you use them. You pay to create and use Contract Wallets because they utilize the valuable computational and storage resources of the network. Paying for the use of thesis resources is part of the gas economics proefje of the Ethereum protocol.
So, since you require gas (which is paid for with ether) to create and use a Contract Wallet, ensure that you have at least one Account with some ether ter it before proceeding. Just 1 ether will be more than enough to attempt out Contract Wallets. A list of gas costs for various wallet operations can be found here and the prevailing gas price is always displayed te the Network Stats pagina.
Types of Contract Wallets: Plain Wallets &, Multisig Wallets
Ordinary Wallets and Multisig Wallets are both examples of Contract Wallets. They are created and wielded by Accounts. With a Ordinary Wallet, only one Account both creates and possesses the wallet. A Multisig Wallet has several possessor Accounts one of which will also be the creator Account.
An Account playing the role of a Contract Wallet creator, will execute this function only once, spil one would expect. Once a Contract Wallet has bot created, the role of managing or controlling the wallet will be the responsibility of the proprietor or owners of the Contract Wallet. The authority of an Account, both when acting spil creator and proprietor of a Contract Wallet, lies te the private key of that Account which is required to sign the necessary transactions. Hence whoever controls that private key is ultimately te charge.
A Plain Wallet seems a lotsbestemming like an Account since only one private key is required to control the wallet, but wij now know that under the bondage mask, they are fairly different.
To create a Ordinary Wallet:
- Click on ADD WALLET CONTRACT.
- Under WALLET CONTRACT TYPE ensure that SINGLE Possessor ACCOUNT is selected, then inject a name for your wallet.
- From the drop-down list, select the Account that will be both the creator and proprietor Account for your fresh Plain Wallet.
Ensure that there is some ether te the Account to voorkant gas costs. About 0.Two ether should be more than enough.
Note that the Create Contract window also displays the gas requirements for this transaction.
Sending Ether from a Plain Wallet
The proces for sending ether from a Elementary Wallet is no different from that for sending ether from an Account. The gas cost will be higher tho’.
Contract Wallets have one minor but nice advantage overheen Accounts: You can lightly sweep (or send ALL of) your balance. This is possible because a Contract Wallet does not pay for gas from its own balance. Rather gas costs are borne by the holder account/s. So you are less likely to see Contract Wallets littered about with petite amounts of weide.
Thesis are M-of-N type wallets, where more than one private key is required to have utter access to the funds held. Ter a typical screenplay, there may be three possessor Accounts with only two required to authorize unlimited spends, making it a 2-of-3 Multisig Wallet. 2-of-2 Multisig Wallets are also common.
Multisig Wallets have the extra functionality of permitting the user to define a daily limit. Spil long spil this daily limit is not exceeded, any one proprietor Account can authorize a spend transaction.
Te practice, Multisig Wallets have two typical use cases:
Use case one: You own some ether and want to store it securely but are worried that just relying on a single private key may not be safe. So you create a Multisig Wallet, perhaps a 2-of-3 wallet, but all the holder Accounts are under your control, that is, you control all the private keys.
Use case two: You set up a Multisig Account jointly wielded by say two people, you and Alice. So you have one private key and Alice the other. Neither of you has access to the other person’s private key of course.
To create a Multisig Wallet:
- Ensure that the addresses of the possessor Accounts are readily available. For example, have them ter a text document so you can lightly copy and paste when required.
- Click on ADD WALLET CONTRACT.
- Under WALLET CONTRACT TYPE select MULTISIGNATURE WALLET CONTRACT.
The default settings for Multisig Wallets is displayed. Te this example, wij are going with the default 2-of-3 setting, but wij have diminished the daily limit to Ten ether.
Note that this Account then shows up spil the very first listed Wallet possessor.
Ensure that there is about 0.Two ether te the Account.
Significant: Do not add a Contract Wallet spil the possessor of a Multisig Wallet. Only Accounts can be owners.
Click on your brand fresh Multisig Wallet ter the Accounts Overview screen and you will see its details, including all holder Accounts.
Sending Ether from a Multisig Wallet
When you spend from a Multisig Wallet, all the signing (holder) Accounts voorwaarde have enough ether ter them to pay for gas costs. If not, you will have to revoke the transaction, which will itself incur a revocation cost, adding insult to injury :).
Screenplay 1: Your Wallet App has access to all the signing (proprietor) Account private keys.
To spend from a Multisig Wallet te Screenplay 1:
- Commence by following the usual proces to spend from any wallet. (See “Sending Ether to Another Account” ter Chapter 1 for details if necessary.)
- Things get a little different when you inject the AMOUNT. You will see a message below the AMOUNT field informing you whether you are within or have exceeded the daily limit. Ter this example, wij will assume you exceed the set daily limit so requiring the utter quota (2-of-3) of Accounts/signatures to authorize the spend.
- When you click the SEND button, you will see the Execute Contract window asking for the password to one of the holder Accounts.
Script Two: Signing (proprietor) Account private keys are te different computers.
The very first step is to ensure that all Wallet Apps participating ter the approval/signing of the multisig transaction have already imported the Multisig Wallet. Say you created a Multisig Wallet te your Wallet App using one of your Accounts and an Account from Alice spil the proprietor Accounts. You won’t have the private key to Alice’s Account of course, that will be on hier pc. However the Wallet App te hier laptop won’t have the Multisig Wallet until she imports it. All she needs to invoer the Multisig Wallet is the wallet’s address.
To invoer a Multisig Wallet into the Wallet App:
- To invoer a Multisig Wallet into an example of the Wallet App, click on ADD WALLET CONTRACT, then select Invoer WALLET and paste the address of the Multisig Wallet te the Wallet Address field. Come in the name of the wallet.
If the importing Wallet App has an proprietor Account of this Multisig Wallet, you will see a corresponding message. You should see something like this:
This Wallet App is now able to sign multisignature transactions involving the imported Multisig Wallet.
To spend from a Multisig Wallet te Script Two:
Ter this example, wij are going to spend an amount ter excess of the daily limit from a 2-of-2 Multisig Wallet with holder Accounts on different computers.
- Go after the initial steps from the Screenplay 1 example above until you see the following te the Wallet App that initiated the transaction:
LATEST TRANSACTIONS ter both Wallet Apps will voorstelling the transaction being confirmed.
Issues Relating to Using Accounts Versus Contract Wallets
I Just Want to Store My Ether Securely
I store my ether ter an Account but only because I don’t want the hassle of backing up and keeping secure more than one private key and password. Maybe a more reasonable compromise would be a 2-of-3 Multisig Wallet, with a daily limit and the same password for all three private keys? Some feel that the single most likely point of failure for most people is actually leaving behind one’s password.
Bottom line: It’s truly a matter of private choice. See this thread and the comments ter this StackExchange response.
Firstly , you already know that sending from a Contract Wallet costs a little more than sending from an Account. Most ordinary users who only periodically send, may be willing to accept the slightly higher gas cost. However, exchanges or other parties that do a lotsbestemming of sending may not. For them, sending from an Account would be more economical.
Secondly , several receivers especially exchanges may not be setup to receive from Contract Wallets. So, if you send ether to Shapeshift for example, their system will not detect your transfer to them. This is because ether transfers initiated by Contract Wallets (te essence code) still do not show up ter some Block Explorers. This situation is improving all the time, for example Block Explorer Etherchain.org is now able to register ether transfers coming from Contract Wallets spil lightly spil from Accounts.
To be safe, for now, use Accounts to send to exchanges and the like.
Thirdly , Ethereum presently works on the principle that the sender always pays , not the possessor of the contract that is triggered. So, if you are sending ether and the receiving address is a customized, gas guzzling Contract Wallet with some fancy code behind it, then you spil the sender will end up paying more ter gas costs. This is an kwestie whether you are sending from an Account or Contract Wallet. The solution for now is to always play it safe and allocate ample gas, say 100,000, so that your transaction does not run out of gas and get cancelled. This is the treatment taken by the Nevel Wallet by default. This punt is expected to be addressed when Serenity arrives, and evidently workarounds are possible even now.
Intuitively, it seems like receiving ether using an Account address or a Contract Wallet address should be no different. The truth is there are differences:
Firstly , you already know that incoming transactions will be listed only when you use a Contract Wallet address.
Secondly , and less evident is the punt related to gas cost. If you use a Contract Wallet spil your receiving address, the sender vereiste have specified enough gas for the transaction to finish. If the sender has specified only the default ondergrens of 21,000 gas for example, the ether transfer will be cancelled due to an out-of-gas error and you will not receive anything. 21,000 gas would have worked if you were using an Account to receive. So, to be safe, use Accounts to receive from exchanges and the like.
It seems clear, that if Contract Wallets are to be more widely and frequently used, there is some re-educating that needs to be done involving both senders and receivers.
Receiving Mining Prizes
If solo mining, you can use either Account or Contract Wallet spil your Etherbase account to receive mining prizes. Evidently the protocol “pays no gas”!
When mining through a pool, it is once again safer to use an Account to receive your prize spil the pool technicus may not specify enough gas to voorkant sending to a Contract Wallet.
Transactions That Run out of Gas
Spil explained above, when you both send or receive ether, you can become involved ter a transaction that runs out of gas. Because the transaction did not specify enough gas, the receiving Contract Wallet’s code execution is reverted and so no ether transfer takes place. The insufficient gas specified will still be consumed, however. Importantly, a transaction that runs out of gas is still a valid transaction and so will be included ter the blockchain and be picked up by all block explorers, adding to the confusion.
Blockchain explorer Ether.Camp is presently the best explorer for identifying an out-of-gas error. Inject the transaction hash into the explorer and it will indicate that the transaction wasgoed cancelled. If you examine the “VM Trace” view you will see that it ran out of gas.
Creating Watch-Only Wallets
If you invoer a Contract Wallet (either Elementary Wallet or Multisig Wallet), following the proces described above, and your Wallet App does NOT have access to the keyfile/s of the holder Account/s, then you will create a Watch-Only Wallet.
An eye-like icon next to the wallet name denotes a Watch-Only Wallet. Watch-Only Wallets update instantly spil the linked wallet’s balance switches.
Where Is Your Wallet Gegevens Stored?
Ter Chapter 1, wij learned where the Wallet App’s Geth knot stores its gegevens. Gegevens not directly related to the Geth knot but created within the Wallet App, such spil gegevens relating to Contract Wallets, transaction history, names, etc. is stored te the following locations:
To backup the Waas directory (Wallet App gegevens):
- Select the Backup spijskaart ter the Menukaart drankbuffet, then select the Backup App Gegevens option.
Copy the entire Waas folder.
Retrieving an Individual Contract Wallet
If you delete a Contract Wallet from your Wallet App by clicking on the Trash icon, you can retrieve it by importing it. (To see the Trash icon select the wallet then hover the cursor overheen the name.) You will need the address of the Contract Wallet. If you haven’t copied the address somewhere (spil you should), you can still get the Contract Wallet address by using a Block Explorer and looking for the transactions sent from the proprietor Account of that Contract Wallet.
Backups of Elementary Wallets and Multisig Wallets
By now, it should be abundantly clear to the reader that contract-based wallets, namely Plain Wallets and Multisig Wallets, are possessed and managed by Accounts. So any backup of a Contract Wallet voorwaarde also include a backup of its holder Account/s. Accounts are backed up by copying their keyfiles or by copying the entire keystore folder spil already described te Chapter 1.
To fully backup a Contract Wallet, you also need to keep a copy of the Nevel folder which can be lightly backed up spil described above.
Restoring a backup is accomplished by simply copying the keyfiles and the Nevel folder back to their original locations.