FRQTAL DOCUMENTATION
  • Bienvenidos
  • ES 馃嚜馃嚫
    • Sobre FRQTAL
      • Empieza hoy
      • Actualizaciones
      • 猸曪笍 Almacenamiento Descentralizado
      • 猸曪笍Blockchain
        • FNFT
        • Prueba de Contenido -Proof of Content (POC)
      • 猸曪笍APP
        • MANUAL DE APP
        • Registro
        • Acceso con Email
        • Acceso con METAMASK
        • Recuperaci贸n de contrase帽a
        • Comprar en Marketplace
        • Creacion de ITEMS
        • Wallet -Billetera
          • Procesador de pagos
        • C贸digos de invitaci贸n
      • Frqtal L1
        • Introducci贸n
        • Nodos Frqtal
        • Validadores
        • Delegadores
        • Staking
        • Contratos inteligentes
      • Caracter铆sticas
    • La Compa帽ia
      • Manuales
        • Manual de uso y protecci贸n de datos T脡CNICO
        • Procesos para mover fondos dentro de las wallets
          • ICO
          • Treasury
          • Comunidad
      • Estructura Interna
      • El Equipo
        • Unete al equipo!
      • Fundaci贸n FRQTAL
      • T茅rminos y condiciones
        • Pol铆tica Usuario NO Grato
        • Pol铆tica de privacidad
        • Pol铆tica de Reclamaciones
        • 馃懢 Lineamientos 脡ticos
        • Pol铆tica de uso aceptable
        • POL脥TICAS, T脡RMINOS Y CONDICIONES DE LOS C脫DIGOS DE INVITACI脫N
        • Monedas estables
      • Cumplimiento | Licencias y normas
        • EULA T茅rminos de uso del acuerdo de licencia de Usuario Final
      • Aviso de privacidad
    • ANIMUS
    • Soporte
      • Contacto
      • Tutoriales
      • Informe Legal
        • Tokenizaci贸n de bienes Raices
        • Tokenizaci贸n de ARTE y Propiedad Intelectual
    • Comunidad
      • Casos de estudio
      • Eventos
      • AirDrops for early adopters
    • APIs
      • B贸ton de pago
Powered by GitBook
On this page
  1. ES 馃嚜馃嚫
  2. Sobre FRQTAL
  3. Frqtal L1

Contratos inteligentes

Contrato Inteligente para el Despliegue de la subnet en AVALANCHE: El siguiente contrato contiene las variables de las billeteras que deben ser desplegadas. Billetera de control, Billetera para el despliegue,

// SPDX-License-Identifier: MIT pragma solidity 
^0.8.13; /********************************************************/ /* 
For learning purposes ONLY. Do not use in production */ /********************************************************/ // 
Download into project folder with `npm install @openzeppelin/contracts` 
import "@openzeppelin/contracts/access/Ownable.sol"; 
// Inherits the Ownable contract so we can use its functions and modifiers contract HOABallot is Ownable { 
// Custom type to describe a Presidential Candidate and hold votes struct Candidate { string name; uint256 votes; } 
// Array of Presidential Candidates Candidate[] public candidates; 
// Add a President Candidate - onlyOwner function addCandidate(string memory _name) public onlyOwner 
{ require(bytes(_name).length > 0, "addCandidate Error: Please enter a name"); 
candidates.push(Candidate({name: _name, votes: 0})); } 
// Remove a Candidate - onlyOwner function removeCandidate(string memory _name) public onlyOwner 
{ require(bytes(_name).length > 0, "removeCandidate Error: Please enter a name"); 
bool foundCandidate = false; uint256 index; bytes32 nameEncoded = 
keccak256(abi.encodePacked(_name)); 
// Set index number for specific candidate for (uint256 i = 0; i < candidates.length; i++) 
{ if (keccak256(abi.encodePacked(candidates[i].name)) == nameEncoded) 
{ index = i; foundCandidate = true; } } 
// Make sure a candidate was found require(foundCandidate, "removeCandidate Error: Candidate not found"); 
// shift candidate to be removed to the end of the array and the rest forward for (uint256 i = index; i < candidates.length - 1; i++) { candidates[i] = candidates[i + 1]; } 
// remove last item from array candidates.pop(); } 
// Reset the President Vote Counts - onlyOwner function resetVoteCount() public onlyOwner { for (uint256 p = 0; p < candidates.length; p++) 
{ candidates[p].votes = 0; } } 
// Add a vote to a candidate by name function addVoteByName(string memory _name) public 
{ require(bytes(_name).length > 0, "addVoteByName Error: Please enter a name"); // Encode name so only need to do once bytes32 nameEncoded = keccak256(abi.encodePacked(_name)); for (uint256 i = 0; i < candidates.length; i++) { // solidity can't compare strings directly, need to compare hash if (keccak256(abi.encodePacked(candidates[i].name)) == nameEncoded) { candidates[i].votes += 1; } } } // Returns all the Presidential Candidates and their vote counts function getCandidates() public view returns (Candidate[] memory) { return candidates; } function getWinner() public view returns (Candidate memory winner) { uint256 winningVoteCount = 0; for (uint256 i = 0; i < candidates.length; i++) { if (candidates[i].votes > winningVoteCount) { winningVoteCount = candidates[i].votes; winner = candidates[i]; } } return winner; } }

PreviousStakingNextCaracter铆sticas

Last updated 1 year ago