Let’s say we have two people, Maya and David. The two agree that David will sell Maya his extra concert ticket, and she will give him one bitcoin in return (that's a pretty expensive ticket). Instead of making a handshake-deal, they can use a smart contract that runs on a blockchain.
The contract is written in computer code, and it has the power to self-execute. A small fee is paid by David and Maya at the beginning, when the contract is initiated. David sends the concert ticket PDF to the contract, and Maya does the same with her bitcoin. Once both have arrived, the bitcoin is sent to David and the ticket is sent to Maya–automatically.
The ability of the contract to act autonomously once certain conditions are met (in this case, once both the ticket and the bitcoin have arrived) is what makes the contract "smart". No human third party was used as an escrow agent.
This is possible because when the contract was coded, Maya and David both digitally signed it, giving it the power to send bitcoins from Maya to David and to send ticket information from David to Maya.
Let's break this down a bit. When the smart contract was written, it included information detailing the following:
After the information is written, David and Maya both digitally sign the contract using something akin to a password. The contract is then sent to the blockchain so it can be carried out.
What’s the point of all this?
The smart contract can act fully autonomously, without the oversight of any human entity. It can be trusted because the code is written on the blockchain, making it immutable.
Theoretically, this kind of contract could be similarly used to transfer the deed to a house, the title of a car, or epic amounts of money when the right conditions are met. This opens up all kinds of avenues for the creation of fraudless, auto-executing agreements as long as the terms are well defined.
It’s easy to see how smart contracts could be used in business, law, finance, and other fields, streamlining and replacing many existing processes for a fraction of the cost!
For this entire process to be worthwhile, writing the contracts on the blockchain has to be easy. As it turns out, the Bitcoin blockchain isn’t so easy to use for these kinds of tasks. It’s better suited for simple transfers of value.
And here lies the motivation for the creation of not just other coins with different features, but different blockchains entirely. Computer scientists have taken Satoshi’s idea and run with it, creating blockchains that make it much easier to write smart contracts or that improve transaction speeds and costs. This is the domain of the altcoin.