└── Contratos ├── Almacenamiento.sol ├── DatosEstructurados.sol ├── Errores.sol ├── Estructura.sol ├── EstructurasDeControl.sol ├── Eventos.sol ├── Funciones.sol ├── Gas.sol ├── Herencia.sol ├── ImplementacionSuma.sol ├── Importacion.sol ├── Interface.sol ├── Mappings.sol ├── Modificadores.sol ├── Polimorfismo.sol ├── Recepcion.sol ├── TokenFungible.sol ├── TokenNoFungible.sol ├── Transferencia.sol └── Variables.sol /Contratos/Almacenamiento.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Almacenamiento { 6 | 7 | string private nombre; 8 | 9 | constructor(string memory palabra) { 10 | nombre = palabra; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Contratos/DatosEstructurados.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Clase { 6 | 7 | struct Alumno { 8 | string nombre; 9 | uint documento; 10 | } 11 | 12 | Alumno[] public alumnos; 13 | 14 | constructor() { 15 | alumnos.push(Alumno({ nombre: "Juan", documento: 12345 })); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Contratos/Errores.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Errores { 6 | 7 | address private owner; 8 | 9 | constructor() { 10 | owner = msg.sender; 11 | } 12 | 13 | function Suma(uint numero1, uint numero2) public view EsOwner() returns (uint) { 14 | return numero1 + numero2; 15 | } 16 | 17 | modifier EsOwner() { 18 | require(msg.sender == owner, "El usuario no es el creador del contrato"); 19 | _; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /Contratos/Estructura.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Estructura { 6 | 7 | constructor() { 8 | 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /Contratos/EstructurasDeControl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract EstructuraDeControl { 6 | 7 | uint[] public numeros; 8 | string public resultado; 9 | 10 | constructor(bool condicion) { 11 | if (condicion) { 12 | resultado = "Condicion True"; 13 | } 14 | else { 15 | resultado = "Condicion False"; 16 | } 17 | 18 | for (uint iterador = 0; iterador < 10; iterador++) { 19 | numeros.push(iterador); 20 | } 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Contratos/Eventos.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Eventos { 6 | 7 | uint[] public numeros; 8 | string public resultado; 9 | 10 | event NotificacionDeCondicion(bool condicion); 11 | 12 | constructor(bool condicion) { 13 | if (condicion) { 14 | resultado = "Condicion True"; 15 | } 16 | else { 17 | resultado = "Condicion False"; 18 | } 19 | 20 | emit NotificacionDeCondicion(condicion); 21 | 22 | for (uint iterador = 0; iterador < 10; iterador++) { 23 | numeros.push(iterador); 24 | } 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Contratos/Funciones.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Funciones { 6 | 7 | function Suma(uint numero1, uint numero2) public pure returns (uint) { 8 | return sumaInterna(numero1,numero2); 9 | } 10 | 11 | function sumaInterna(uint numero1, uint numero2) private pure returns(uint) { 12 | return numero1 + numero2; 13 | } 14 | 15 | uint private resultado; 16 | 17 | function ObtenerResultado() public view returns (uint) { 18 | return resultado; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /Contratos/Gas.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Gas { 6 | 7 | uint public numero; 8 | 9 | function asignarNumero(uint entrada) public { 10 | numero = entrada; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Contratos/Herencia.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "./Interface.sol"; 6 | import "./Modificadores.sol"; 7 | 8 | contract Herencia is Suma, Modificadores { 9 | 10 | constructor(string memory nombreNuevo) Modificadores(nombreNuevo) { 11 | 12 | } 13 | 14 | function sumar(uint numero1, uint numero2) public override EsOwner() view returns(uint) { 15 | return numero1 + numero2; 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Contratos/ImplementacionSuma.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "./Interface.sol"; 6 | 7 | contract ImplementacionSuma is Suma { 8 | 9 | function sumar(uint numero1, uint numero2) public override pure returns (uint) { 10 | return numero1 + numero2; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Contratos/Importacion.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "@openzeppelin/contracts/utils/math/SafeMath.sol"; 6 | 7 | contract Importacion { 8 | 9 | function sumarNumeros(uint numero1, uint numero2) public pure returns (uint) { 10 | return SafeMath.add(numero1,numero2); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Contratos/Interface.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | interface Suma { 6 | 7 | function sumar(uint numero1, uint numero2) external returns (uint); 8 | 9 | } -------------------------------------------------------------------------------- /Contratos/Mappings.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Saldo { 6 | 7 | mapping(address => uint) public balance; 8 | 9 | enum Estado { Iniciado, Finalizado } 10 | 11 | Estado public estadoDelContrato; 12 | 13 | constructor() { 14 | estadoDelContrato = Estado.Iniciado; 15 | 16 | balance[msg.sender] = 1000; 17 | 18 | estadoDelContrato = Estado.Finalizado; 19 | } 20 | 21 | 22 | } -------------------------------------------------------------------------------- /Contratos/Modificadores.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Modificadores { 6 | 7 | address private owner; 8 | string private nombreOwner; 9 | 10 | constructor(string memory nombre) { 11 | owner = msg.sender; 12 | nombreOwner = nombre; 13 | } 14 | 15 | function Suma(uint numero1, uint numero2) public view EsOwner() returns (uint) { 16 | return numero1 + numero2; 17 | } 18 | 19 | modifier EsOwner() { 20 | if (msg.sender != owner) revert(); 21 | _; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /Contratos/Polimorfismo.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "./Interface.sol"; 6 | 7 | contract Polimorfismo { 8 | 9 | function sumarDesdeContrato(uint numero1, uint numero2, address direccionContrato) 10 | public returns(uint) { 11 | Suma interfaceSuma = Suma(direccionContrato); 12 | return interfaceSuma.sumar(numero1,numero2); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /Contratos/Recepcion.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Recepcion { 6 | 7 | mapping(address => uint) balances; 8 | uint public saldoEnviado; 9 | 10 | receive() external payable { 11 | balances[msg.sender] += msg.value; 12 | } 13 | 14 | fallback() external payable { 15 | 16 | } 17 | 18 | function recibirSaldo(uint numero) public payable { 19 | saldoEnviado = msg.value; 20 | 21 | uint monto = numero; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /Contratos/TokenFungible.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 6 | 7 | contract TokenFungible is ERC20("TokenFungible", "TF") { 8 | 9 | constructor() { 10 | _mint(msg.sender, 1000); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Contratos/TokenNoFungible.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; 6 | 7 | contract TokenNoFungible is ERC721("TokenNoFungible","TNF") { 8 | 9 | constructor() { 10 | _mint(msg.sender, 1); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Contratos/Transferencia.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Transferencia { 6 | 7 | constructor() payable { 8 | 9 | } 10 | 11 | function transferenciaPorSend(address destino, uint monto) public returns(bool) { 12 | bool salida = payable(destino).send(monto); 13 | return salida; 14 | } 15 | 16 | function transferenciaPorTransfer(address destino, uint monto) public { 17 | payable(destino).transfer(monto); 18 | } 19 | 20 | function transferenciaPorCall(address destino, uint monto) public returns (bool) { 21 | (bool salida, bytes memory respuesta) = destino.call{value:monto, gas: 1000}(""); 22 | return salida; 23 | } 24 | } -------------------------------------------------------------------------------- /Contratos/Variables.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.7.0 <0.9.0; 4 | 5 | contract Estructura { 6 | 7 | int cantidad; 8 | uint cantidadSinSigno; 9 | address direccion; 10 | bool firmado; 11 | 12 | constructor(bool estaFirmado) { 13 | direccion = msg.sender; 14 | firmado = estaFirmado; 15 | } 16 | 17 | } --------------------------------------------------------------------------------