0Pricing
Web3 & DApp Development Fundamentals · Aula

Introdução ao Solidity

Conheça a sintaxe e a estrutura do Solidity e a declaração básica de contratos, incluindo as palavras-chave pragma e contract.

Introdução ao Solidity é uma aula grátis de Web3 & DApp Development Fundamentals no CoddyKit. Esta é a aula 1 de 3. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Web3 & DApp Development Fundamentals, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Web3 & DApp Development Fundamentals inclui 3 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em 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!

Perguntas Frequentes

A aula “Introdução ao Solidity” é grátis?

Sim — o texto completo de “Introdução ao Solidity” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Web3 & DApp Development Fundamentals, atualize para CoddyKit PRO. O curso de Web3 & DApp Development Fundamentals inclui 3 aulas no total.

O que vou aprender em “Introdução ao Solidity”?

Conheça a sintaxe e a estrutura do Solidity e a declaração básica de contratos, incluindo as palavras-chave pragma e contract. Você pratica Web3 & DApp Development Fundamentals com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Web3 & DApp Development Fundamentals?

Nenhuma experiência prévia é necessária. Web3 & DApp Development Fundamentals no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 3.

Quanto tempo leva a aula “Introdução ao Solidity”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Web3 & DApp Development Fundamentals?

Sim. Cada aula de Web3 & DApp Development Fundamentals inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Introdução ao Solidity
  2. Variáveis e Tipos de Dados
  3. Funções e Estruturas de Controle
← Voltar para Web3 & DApp Development Fundamentals