Last active
January 23, 2022 17:10
-
-
Save juanlcoto/15c70f0402de44654f097cb80cc05cea to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.7.6+commit.7338295f.js&optimize=false&runs=200&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
//Versión | |
pragma solidity ^0.7.0; | |
contract funciones_globales{ | |
//Función msg.sender | |
function MsgSender() public view returns(address){ | |
return msg.sender; | |
} | |
function Now() public view returns(uint){ | |
return block.timestamp; | |
} | |
//Función block.coinbase | |
function BlockCoinbase() public view returns(address){ | |
return block.coinbase; | |
} | |
//Función block.difficulty | |
function BlockDifficulty() public view returns(uint){ | |
return block.difficulty; | |
} | |
//Función block.number | |
function BlockNumber() public view returns(uint){ | |
return block.number; | |
} | |
//Función tx.grasprice | |
function txGasPrrice() public view returns(uint){ | |
return tx.gasprice; | |
} | |
//Función keccak256. Espera datos de tipos bytes | |
//Función abi.encodePacked para pasar datos a bytes. Antes debemos usar la sentencia pragma experimental ABIEncoderV2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.7.0; | |
pragma experimental ABIEncoderV2; | |
contract hash{ | |
//Computo de hash de un string | |
function calcularHash(string memory _cadena) public pure returns(bytes32){ | |
return keccak256(abi.encodePacked(_cadena)); | |
} | |
//Computo de hash de un string, un entero y una dirección | |
function calcularHashDos(string memory _cadena, uint _k, address _direccion) public pure returns(bytes32){ | |
return keccak256(abi.encodePacked(_cadena, _k, _direccion)); | |
} | |
//Computo de hash de un string, un entero y una dirección, más otro string y entero que no están en la variable | |
function calcularHashTres(string memory _cadena, uint _k, address _direccion) public pure returns(bytes32){ | |
return keccak256(abi.encodePacked(_cadena, _k, _direccion, "hola", uint(2))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment