A blockchain is a shared, immutable electronic ledger (or digital database) that records of transactional data, referred to as transactions. The block in blockchain refers to a block of transactions that's been broadcast to the network. The chain refers to a string of these blocks in chronological order.
When a new block of transactions is securely validated by the network, it is attached to the end of the existing chain. This chain of blocks is an growing ledger of transactions, each of which can be traced, providing accountability and transparency unavailable on traditional ledgers.
Smart contracts provide controlled access and a range of functions (such as querying, transacting, and updating state) to blockchain users. Smart contracts encapsulate data and keep it consistent across the network. They can allow or restrict participants from executing certain functions, and can restrict access to the network itself. Smart contracts are written in Solidity (the most popular smart contract language), Vyper, and Serpent.
Smart contracts work on the general conditional principle (if/then) of programming, written into code on the blockchain. When conditions defined in the contract are met and verified, it is submitted as a transaction onto the chain where a network of peers validate and execute it. When the transaction is complete, the chain is then updated and its new state is immutable, meaning that you cannot change the state once it is written to the chain.
Transactions can be public or private. The contents of a public transaction are visible to all participants on the blockchain network, and the contents of private transactions can only be seen by parties of the transaction, or those that have been granted access to view it.