Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previa | |||
| bc:solidity [2024/09/25 13:34] – thejuanvisu | bc:solidity [2024/09/25 14:04] (actual) – thejuanvisu | ||
|---|---|---|---|
| Línea 192: | Línea 192: | ||
| emit IntegersAdded(_x, | emit IntegersAdded(_x, | ||
| return result; | return result; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Mapas ==== | ||
| + | Tipos de datos complejos similares a las hashtables. En el siguiente ejemplo se puede ver como se alamcena un uint con el saldo de un usuario. El tipo de datos address almacena la clave y uint el valor. | ||
| + | < | ||
| + | mapping(address => uint) public saldo; | ||
| + | </ | ||
| + | |||
| + | ==== Variables especiales y funciones ==== | ||
| + | msg.sender(address): | ||
| + | |||
| + | < | ||
| + | contract NumeroFavorito { | ||
| + | mapping(address=> | ||
| + | | ||
| + | function establecerNumero(uint _numero) public{ | ||
| + | numeroFavorito[msg.sender] = _myNumber; | ||
| + | } | ||
| + | | ||
| + | function CualEsMiNumeroFavorito() public view returns (uint){ | ||
| + | return numeroFavorito[msg.sender]; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Estructuras de control ==== | ||
| + | * if-else | ||
| + | * while | ||
| + | * do-while | ||
| + | * for | ||
| + | |||
| + | < | ||
| + | if(x<1){ | ||
| + | return 0; | ||
| + | } else if (x=0){ | ||
| + | return 1; | ||
| + | } else{ | ||
| + | return 2; | ||
| } | } | ||
| </ | </ | ||
| Línea 219: | Línea 258: | ||
| {{: | {{: | ||
| </ | </ | ||
| + | |||
| + | |||