Programmatically speaking, a miner will create a block with the message, will append a nonce (any random hexadecimal value), and then hash it. Blockchain uses a SHA256 hashing technique which means that any length of string can be put as input and after hashing it will produce a fixed length string of 256 bits. This will make the block approved and will show the proof-of-work. Proof-of-work is what makes it almost unhackable. A hacker who would want to get the message would have to add as many nonce to get the same result. This is a cryptographic puzzle that takes high computational power and a lot of time. The very reason I mentioned it as ‘almost unhackable’. Another way to establish a proof-of-work is to use a newer technology called zk-snark (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge). This still validates the work but doesn’t reveal any knowledge of the data. To understand it better, you would need to understand how Ethereum (an open-source, public, blockchain-based distributed computing platform and operating system) adopted and implemented it. Now you got the juice of it and so let’s complete the contract by signing it. To make it digitally signed, a public-private key pair is to be used. Suppose, X is creating a smart contract for Y. Y has its own public-private key pair. X will then encrypt the contract with Y’s public key. Y will then be able to decrypt the smart contract from its own private key. Thus, you get a smart contract.