You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
2 Hrs
54 Min
45 Seg

Instalando en una testnet

14/21
Resources

How to bring a smart contract to a Celo testnet?

When we talk about deploying smart contracts on a testnet, we mean moving our code from the local development environment to a public platform where we can interact with other users and developers. This process in a testnet is essentially the same as for the main Celo network, only we do not incur costs.

What tools do we need?

Before you start, make sure you meet the following requirements:

  • Digital wallet: You will need a wallet such as Celo Wallet or, if you prefer, Valora Wallet in its testnet version. Both work in a similar way to MetaMask.
  • Faucet for test cryptocurrencies: You can request test cryptocurrencies from a faucet. This will allow you to transact on the testnet at no cost.
  • Remix IDE: This tool simplifies the compilation and deployment of smart contracts.

Also, if you use MetaMask, verify that the right network is configured, in this case, the Alfajores de Celo network.

How to deploy the contract with Remix IDE?

  1. Compiling the contract:Within Remix, select and compile your contract. Make sure there are no errors to advance to the next step.

  2. Environment Setup:Change the deployment environment in Remix from "JavaScript VM" to "Injected Web 3 Provider". This will connect Remix to your digital wallet to enable the transaction.

  3. Account and balance verification:Once the environment is set up, check that there is sufficient balance in the selected account. If you need more cryptocurrencies, request them from the faucet mentioned above.

  4. Deploy the contract:Click on "Deploy" to start the process. If you are using MetaMask, you will need to confirm the transaction by indicating the estimated cost.

  5. Transaction monitoring:Wait for confirmation that the transaction has been processed. Once completed, the contract will be accessible on the testnet.

What to consider when sharing the deployed contract?

Once the contract is deployed on the testnet, a unique address is generated for it. This address allows people other than you to interact with the contract. This is a crucial aspect for collaborative testing and for receiving feedback from other developers.

Are there alternatives for deploying multiple contracts?

Although the process described above is effective, it can be tedious if you need to deploy multiple contracts. In these cases, more advanced and automated tools such as Hardhat can be helpful. Hardhat offers a more robust and simpler way to work with multiple contracts, allowing for a more efficient workflow.

With these instructions, you'll be ready to take your smart contracts to the next level in the Celo environment. Get excited to experiment and continue learning in this exciting field of blockchain technology!

Contributions 3

Questions 2

Sort by:

Want to see more contributions, questions and answers from the community?

Cómo registrar la testnet Alfajores a Metamask:

  1. Abrir Metamask
  2. Abrir redes y seleccionar agregar una nueva.
  3. Ingresar la información de la testnet Alfajores.
Network Name: Celo (Alfajores Testnet)
New RPC URL: https://alfajores-forno.celo-testnet.org
Chain ID: 44787
Currency Symbol (Optional): CELO
Block Explorer URL (Optional): https://alfajores-blockscout.celo-testnet.org

Testnet es similar a la red de celo real, pero sin tener costos.
Tenemos que tener descargado Celo Wallet que es un complemento, es similar a metamask.

Pedir al faucet que no den una serie de criptomonedas.
https://celo.org/developers/faucet

En la clase anterior borra árbitro y en esta si esta, solo revisen eso, por si no les aparece en el menú de “deploy & run transactions”. Así como borro todas las igualaciones debajo del constructor. Chequen eso nomas panas.
Aquí les dejo el código ya corriendome:

pragma solidity ^0.8;

import "@openzeppelin/contracts/access/Ownable.sol";

contract Proyecto is Ownable {
    
    address public comprador;
    address public vendedor;
    address public arbitro;
    bool public depositoListo;
    bool public compradorOK;
    bool public pagoListo;

    uint public montoPago;

    modifier onlyComprador() {
        require(msg.sender==comprador,"No es el comprador");
        _;
    }

    constructor(address _comprador, address _vendedor, uint _monto, address _arbitro) {
    }

    //deposita el comprador 
    function depositoPago() payable public onlyComprador {
        require(msg.value == montoPago,"No es el valor correcto");
        depositoListo = true;
    }

    function compradorConfirmaOK() public onlyComprador {
        compradorOK=true;
    }

    //retira el vendedor 
    function retiraPago() public {
        payable(vendedor).transfer(montoPago);
        pagoListo=true;
    }

    //si el vendedor no entrega el producto, intervien el arbitro
    function pagarPorArbitro() public onlyOwner {
        payable(vendedor).transfer(montoPago);
        pagoListo=true;
    }


}