What Is a Smart Contract?
What is a smart contract? A smart contract is a program deployed on a blockchain that runs automatically according to pre-written code, carrying out an action such as transferring assets once its conditions are met. Ethereum's official developer documentation describes it as a program that runs on the Ethereum blockchain, made up of code (its functions) and data (its state) that sits at a specific address on the chain. The Bank for International Settlements (BIS) gives a similar definition in its 2023 Annual Economic Report: a smart contract is a self-executing application on a programmable platform that triggers an action when pre-specified conditions are met.
What is a smart contract? A smart contract is a program deployed on a blockchain that runs automatically according to pre-written code, carrying out an action such as transferring assets once its conditions are met. Ethereum’s official developer documentation describes it as a program that runs on the Ethereum blockchain, made up of code (its functions) and data (its state) that sits at a specific address on the chain. The Bank for International Settlements (BIS) gives a similar definition in its 2023 Annual Economic Report: a smart contract is a self-executing application on a programmable platform that triggers an action when pre-specified conditions are met.
How Does a Smart Contract Work?
According to the Ethereum documentation, a smart contract is itself a type of Ethereum account: it has a balance and can receive transactions, but it is not controlled by a user. Instead, it is deployed to the network and runs as programmed. To use a contract, a user sends it a transaction that calls one of the functions defined in it. A contract can set out rules like an ordinary contract and enforce them automatically through code; by default it cannot be deleted, and interactions with it cannot be reversed. Developers usually write contracts in Solidity or Vyper and compile them before deploying to the Ethereum Virtual Machine. Deployment is itself a transaction that requires gas, and it costs far more than a simple ETH transfer.
Contracts can also call one another. The Ethereum documentation compares public contracts to open APIs: one contract can call others to extend what it can do, and can even deploy new contracts. The BIS likewise sees this composability, together with contingent execution, as two key changes that tokenization brings: several actions can be bundled and executed as one package, and they happen only when conditions are met.
Where Does the Idea of a Smart Contract Come From?
The term is much older than blockchain. In his 1996 article “Smart Contracts: Building Blocks for Digital Markets,” Nick Szabo defined a smart contract as a set of promises specified in digital form, including the protocols within which the parties perform on those promises. He explained that they are called “smart” because they are far more functional than paper contracts, and that no artificial intelligence is implied. The basic idea is to embed contract terms in software and hardware so that breaching the contract becomes costly for the party in breach.
Szabo saw the vending machine as the primitive ancestor of smart contracts: it takes in coins and, through a simple mechanism, gives out change and the product fairly. The Ethereum documentation uses the same metaphor: with the right inputs, a certain output is guaranteed, and just as a vending machine removes the need for a sales clerk, smart contracts can replace intermediaries in many industries.
What Can Smart Contracts Be Used For?
Smart contract use cases include decentralized finance, stablecoins and tokenized assets, conditional payments and securities and FX settlement, and managing funds with multisig contracts. Writing rules such as multisig approval and spending limits into the account itself is the basis of smart contract wallets.
What Are the Risks of Smart Contracts?
The main risk is bugs in the code. Ethereum’s smart contract security documentation notes that deployed code usually cannot be changed to patch a flaw, and that assets stolen from contracts are very hard to trace and mostly cannot be recovered. By the documentation’s estimate, the total value stolen or lost because of security defects in smart contracts is easily over $1 billion, including the 3.6 million ETH stolen in The DAO hack, about $30 million lost in the Parity multisig wallet hack, and more than $300 million worth of ETH locked forever in the Parity frozen wallet incident. The documentation recommends independent code review such as audits to catch problems, while cautioning that audits will not find every bug.
Contracts also have built-in limits. The Ethereum documentation explains that a contract cannot fetch offchain data on its own, because relying on external information could jeopardize consensus, so it needs an oracle when offchain data is required; a single contract is also capped at 24KB. For the people using contracts, a transaction that calls a contract is just a string of data, and signing it without understanding it exposes them to the risk of blind signing.
Conclusion
Smart contracts turn contract rules into on-chain code that runs automatically when conditions are met, and they are used for conditional payments, securities and FX settlement, and multisig asset management. Once deployed, however, the code is hard to change, and losses from bugs are hard to recover. Safeheron’s MPC Wallet-as-a-Service provides businesses with MPC key management and a policy engine.
Is your business using smart contracts to manage on-chain assets or handle settlement?
Looking for a secure way to manage digital assets?
Talk to our experts and find the right solution for your business.
Request a DemoLooking for a secure way to manage digital assets?
Talk to our experts and find the right solution for your business.