XRP Ledger Apex is back in Amsterdam Register Now
Estimated reading time:

10 minutes

Difficulty:

Beginner

Concepts covered:
  • Blockchain
  • Community
  • Hooks
  • Sidechains

Key takeaway:

Smart contracts are a way to write code that controls how assets move on a blockchain.

Lesson 4

What is a smart contract?

Adding code to manual payments

Smart contracts are digital contracts that execute automatically when certain conditions are met. Stored on a blockchain, smart contracts are tamper-proof and cannot be changed or deleted.

They were first proposed by Nick Szabo in 1994, but they didn’t gain prominence until the release of the Ethereum blockchain in 2015.
In the context of our community, smart contracts can build trust between traders, reduce costs, and speed up transactions.

Smart contracts could be used to enforce a pre-established agreement around carbon credit usage within the community. For example, once a community member accumulates a certain number of carbon credits (e.g., by planting trees or installing solar panels), one tokenized ounce of gold is granted from the community treasury to that individual’s account automatically. A lot less bureaucracy!

In another example, a smart contract could record the live temperature inside a milk storage facility. If the temperature exceeds a certain threshold, the milk could automatically become void for safety reasons. As all records are recorded onto the blockchain where they cannot be tampered with by the milk supplier, the community has full transparency into the conditions of their milk. There’s no need for a middleman to check the milk and approve the transaction—the smart contract does it automatically.

Do you need smart contracts to build on a blockchain?

Not always. The majority of developers don’t need to write smart contracts to interact with a blockchain. However, some may need them to improve the functionalities that a blockchain offers, depending on which one they are building on.

The XRP Ledger does not have native smart contracts, but there are different ways developers can add these functionalities to it.

Hooks

Hooks are small pieces of code that allow logic to be executed before and/or after XRPL transactions. For example, if X occurs, then execute Z. We take a closer look at hooks in the ‘Intro to new innovations on the XRPL‘ module.

Note that Hooks are not yet live on the XRP Ledger and are in the proposal stage for now.

END OF LESSON

Things got a little technical there. Let's make sure you're still with us.

Do you need smart contracts to build on the XRPL?
What is a smart contract?
What could a smart contract be used for?
Which coding language is required to build on the XRPL?
Who first proposed the concept of smart contracts?