Understanding ethereum smart contracts a comprehensive guide
Understanding ethereum smart contracts a comprehensive guide
Understanding ethereum smart contracts a comprehensive guide follows Ethereum’s own introduction. A smart contract there is a program that runs on Ethereum: code and data at an address. It is not investment advice, and it does not tell you to deploy a contract or to send funds to one.
The Ethereum introduction to smart contracts is the only source for the points below. Where that page prints a size, a balance, or a signature count, those figures stay on the page.
What understanding ethereum smart contracts a comprehensive guide covers
The page says a smart contract is an Ethereum account. It can hold a balance and it can be the target of a transaction. It is not controlled by a user after deployment. It runs as it was programmed. A user account interacts with it by submitting a transaction that calls a function the contract defines. The page says contracts can state rules, the way an ordinary contract does, and enforce those rules in code. It also says contracts cannot be deleted by default, and that interactions with them are irreversible. Those two sentences are properties of the system as the page states them. They are not a promise about any particular contract you might find.
The page’s picture for this is a vending machine, credited to Nick Szabo. With the inputs the machine expects, the output follows from the machine’s logic. The page shows that idea as a short Solidity example: an owner set at deployment, a function only that owner may call to refill, and a purchase function that checks payment and stock before it moves the item. The example’s amounts stay in the example on the page. This article does not copy them and does not ask you to deploy that sample.
Who can deploy, and what they cannot see
The page says anyone can write a contract and deploy it. Deployment is itself a transaction, so it costs gas, and the page says that cost is higher than a simple transfer. Two languages it names are Solidity and Vyper. The contract must be compiled before the network’s virtual machine can store it. The page points at its own notes on languages and compilation for that step. This article stops at the names.
Contracts on Ethereum are public. The page compares them to open APIs: one contract can call another, and a contract can deploy a contract. That is the composability section. It does not mean a private arrangement stays private. What you put in the contract is visible to the network.
The page’s limitation section says a contract cannot pull real-world events by itself, because it cannot fetch off-chain data. The page says that limit is intentional, because outside data could put consensus at risk. The tool it names for bringing outside data in is an oracle. A second limit is a maximum contract size. The number is on the page, along with the name of a pattern the page says can work around it. This article does not repeat the number.
More than one signature
The page describes a multisig contract as an account that requires more than one valid signature before a transaction runs. It gives the reasons on the page: no single key is the only way in, responsibility is split, and losing one key does not by itself empty the contract. It also says this pattern is used for simple DAO governance. The exact counts of signatures it offers as common examples stay on the page. Understanding ethereum smart contracts a comprehensive guide does not pick a count for you.
Read the page in this order. First the definition: code and state at an address, an account, not a user. Then the vending-machine picture, including the warning that a call cannot be undone. Then deployment as a transaction in Solidity or Vyper, after compilation. Then composability, the off-chain limit, and the multisig description. If a paragraph you remember is not in that list, it did not come from this source.
Do not treat a token price, a yield, or an exchange listing as part of the definition. They are not on the page. If a contract’s function sends assets when it is called, the page’s irreversibility line is the reason to read the function before you call it. This article does not review any live contract and does not name one to use.
A wallet is how the page says a person usually submits the transaction that calls a function. The contract does not become yours because you called it, unless the code you are reading says so, and even then only in the way that code says. The owner in the page’s sample is the address that deployed it, and only that address may refill. Another address may purchase, if it meets the checks. That split is the sample. It is not a rule for every contract on the network.
When you look at a contract someone else deployed, the page gives you the questions, not a rating. Is the code at an address? Does a call match a function that code defines? Can the call be reversed? The page’s answer to the last question is that interactions are irreversible by default. Gas is the fee for the transaction, including deployment. The page does not set a gas price here, so this article does not either.
Keep three roles separate when you retell the page. The deployer is the account that sends the deployment transaction and, in the sample, becomes the owner. A caller is any account that later sends a transaction naming one of the contract’s functions. The contract itself is the account that holds the code and the state. Mixing those three is how a sentence starts to claim that calling a function transfers ownership. The sample does not say that. The purchase function in the sample changes balances according to its checks. It does not hand the caller the owner variable.
The page also says a contract can define rules and enforce them in code, in place of an intermediary the way a vending machine stands in for a cashier. That is the page’s comparison. It is not a statement that a court, a bank, or a warranty disappears. If you need a legal conclusion, it is not in this source. Stay with the mechanism: inputs the code expects, checks the code runs, and a result the code writes to its own state.
Compilation is a step the page insists on and this article will not skip past in silence. You write Solidity or Vyper. A compiler turns that text into the form the virtual machine stores. Until that form is deployed in a transaction, there is no contract at an address, and there is nothing for another account to call. After deployment, editing the source file on your computer does not edit the code already at the address. The page’s line that contracts cannot be deleted by default is the matching half of that fact. A new deployment is a new address. It does not rewrite the old one.
Public code is the other half of composability. Because the page treats contracts as open APIs, another contract can call yours, and you can call one that is already there. You can read what is on chain. You should assume other people can read it too. A secret written into the contract state is not a secret the page offers you. Leave secrets off the contract.
A call is a transaction, so it has the same shape as any other transaction the page assumes you already know: a signature from the caller, a destination, and a fee. The destination is the contract address. The data in the transaction names the function and the arguments. The contract runs that function and writes the new state if the checks pass. If a check fails, the page’s sample uses a require line and the call does not complete the change. You still sent a transaction. The page does not say the fee comes back in full. Read the gas section on the site before you assume a failed call is free.
Oracles sit outside that loop on purpose. The contract does not open a web page. Someone, or some other contract fed by an oracle, has to put the outside fact into a transaction. Until that transaction is in a block, the contract has not seen the fact. The page’s reason is consensus: every node has to be able to rerun the same steps. A contract that fetched a private website could see a different answer on each node. That is why the limit is there. It is also why an oracle is a new trust decision the page names and this article does not pick for you.
Multisig does not change the irreversibility line. It changes how many signatures must be present before the transaction is valid. Once enough signatures exist and the transaction is in a block, the page still treats the interaction as irreversible by default. Splitting keys is the page’s protection against one lost key. It is not a rewind button. If the page’s common signature counts matter to a setup you are reading, copy them from the page, not from memory.
Understanding ethereum smart contracts a comprehensive guide ends on those questions. Open the Ethereum page for the sample code, the size limit, and the signature counts. The photograph is Backlit laptop keyboard keys by ChromeGames923, Wikimedia Commons, licence CC BY-SA 4.0.
