0Pricing
Web3 & DApp Development Fundamentals · Lección

Introducción a Solidity

Obtenga una visión general de la sintaxis y la estructura de Solidity, así como de la declaración básica de contratos, incluidas las palabras clave pragma y contract.

Introducción a Solidity es una lección gratuita de Web3 & DApp Development Fundamentals en CoddyKit. Esta es la lección 1 de 3. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Web3 & DApp Development Fundamentals, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Web3 & DApp Development Fundamentals incluye 3 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Meet Solidity: Language of Smart Contracts

Welcome to Solidity! It's the primary language for writing smart contracts on blockchain platforms like Ethereum.

Think of smart contracts as self-executing agreements stored on a blockchain. Learning Solidity opens the door to building decentralized applications (DApps).

Why Solidity Matters

Solidity is a high-level, object-oriented language. It's specifically designed to implement business logic for DApps.

It enables you to create digital tokens, build decentralized finance (DeFi) protocols, and manage digital assets securely on a blockchain.

Your First Solidity File

Every Solidity smart contract lives in a file ending with the .sol extension.

  • Just like a .js file for JavaScript.
  • Or a .py file for Python.
  • The first line of a Solidity file often defines the compiler version to be used.

The Pragma Directive

The pragma directive is crucial. It tells the Solidity compiler which version to use for your contract.

For example, pragma solidity ^0.8.0; means "use any compiler version from 0.8.0 up to, but not including, 0.9.0."

This ensures your contract compiles predictably and avoids unexpected behavior from future compiler changes.

Declaring a Contract

In Solidity, the fundamental building block for your smart contract is the contract keyword.

  • It's similar to a "class" in object-oriented programming languages.
  • Your entire smart contract's logic, including variables and functions, will live inside a contract block.

Our First Basic Contract

Let's put pragma and contract together. This is the most basic, yet complete, Solidity contract you can write.

It doesn't do much yet, but it's ready to be compiled and deployed!

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract MyFirstContract {
  // This contract is currently empty!
}

Comments in Solidity

Comments help explain your code to others and your future self. They are ignored by the compiler.

  • Single-line comments start with //.
  • Multi-line comments are enclosed by /* and */.
  • The SPDX-License-Identifier is a special comment used to specify the contract's license.

Contract Name & Structure

Contract names usually start with an uppercase letter, following common programming conventions (e.g., MyFirstContract).

The code inside the curly braces {} defines the contract's logic. This is where you'll add state variables, functions, and events as you learn more.

Quick Check: Pragma Purpose

The pragma solidity ^0.8.0; line is essential for smart contract development. What is its primary role?

Recap: Your Solidity Journey Begins!

You've learned the very basics of Solidity!

  • We covered the .sol file extension.
  • The critical pragma directive for compiler versions.
  • The fundamental contract keyword.
  • How to add comments for code clarity.

Next, we'll dive deeper into variables and data types!

Preguntas frecuentes

¿La lección «Introducción a Solidity» es gratis?

Sí — el texto completo de «Introducción a Solidity» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Web3 & DApp Development Fundamentals, actualiza a CoddyKit PRO. El curso de Web3 & DApp Development Fundamentals incluye 3 lecciones en total.

¿Qué aprenderé en «Introducción a Solidity»?

Obtenga una visión general de la sintaxis y la estructura de Solidity, así como de la declaración básica de contratos, incluidas las palabras clave pragma y contract. Practicas Web3 & DApp Development Fundamentals con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Web3 & DApp Development Fundamentals?

No se requiere experiencia previa. Web3 & DApp Development Fundamentals en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 3.

¿Cuánto tiempo toma la lección «Introducción a Solidity»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Web3 & DApp Development Fundamentals?

Sí. Cada lección de Web3 & DApp Development Fundamentals incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Introducción a Solidity
  2. Variables y tipos de datos
  3. Funciones y estructuras de control
← Volver a Web3 & DApp Development Fundamentals