Deploying to Testnet - Discussion

Hello @Erno

Both these links worked:- https://teth.bitaps.com/ and https://faucet.dimensions.network/

Thanks again

3 Likes

@filip I also have the same error with faucet. The alternative that Miko posted also does not work for me. Can you advise what I can do to load metamask TestNet?

Hi @Li_Sun

Googling ‘faucet raupsten’
The first link gives you this site https://faucet.ropsten.be/ which is working well.
Otherwise it’s probably blocked in you localtion because i just tested it and it’s working.
Try to use a vpn or use an other faucet find online , good luck :slight_smile:

2 Likes

Thanks. with https://faucet.ropsten.be/ works.
I was getting “Too many requests” error with https://faucet.metamask.io

2 Likes

@filip I did not have the costs(100 wei) in my createPerson function and when I added it I got the following error: DeclarationError: Undeclared identifier. The problem seems to be with “costs()”.

Please advise.

@CryptoBuddha
Thanks for reaching out!
Can you please elaborate your question more?
error: DeclarationError: Undeclared identifier means your variable is not declared.

1 Like

I changed this:

function createPerson(string memory name, uint age, uint height) public payable {…}

to this:

function createPerson(string memory name, uint age, uint height) public payable costs (100 wei) {…}

And got the above error. Also when I hover over the red box that indicates an error it says the problem is with the costs keyword, however, not sure why or how to fix it.

@CryptoBuddha
Can you share me the program of
modifier costs ?

1 Like
import "./Ownable.sol";
import "./Destroyable.sol";
pragma solidity 0.5.12;

contract HelloWorld is Ownable, Destroyable{

    struct Person {
      uint id;
      string name;
      uint age;
      uint height;
      bool senior;
    }

    event personCreated(string name, bool senior);
    event personDeleted(string name, bool senior, address deletedBy);


    
    uint balance = 0;

    mapping (address => Person) private people;
    address[] private creators;

    function createPerson(string memory name, uint age, uint height) public payable costs (100 wei) {
      require(age < 150, "Age needs to be below 150");
      balance += msg.value;
        //This creates a person
        Person memory newPerson;
        newPerson.name = name;
        newPerson.age = age;
        newPerson.height = height;

        if(age >= 65){
           newPerson.senior = true;
       }
       else{
           newPerson.senior = false;
       }

        insertPerson(newPerson);
        creators.push(msg.sender);

        assert(
            keccak256(
                abi.encodePacked(
                    people[msg.sender].name,
                    people[msg.sender].age,
                    people[msg.sender].height,
                    people[msg.sender].senior
                )
            )
            ==
            keccak256(
                abi.encodePacked(
                    newPerson.name,
                    newPerson.age,
                    newPerson.height,
                    newPerson.senior
                )
            )
        );
        emit personCreated(newPerson.name, newPerson.senior);
    }
    function insertPerson(Person memory newPerson) private {
        address creator = msg.sender;
        people[creator] = newPerson;
    }
    function getPerson() public view returns(string memory name, uint age, uint height, bool senior){
        address creator = msg.sender;
        return (people[creator].name, people[creator].age, people[creator].height, people[creator].senior);
    }
    function deletePerson(address creator) public onlyOwner {
      string memory name = people[creator].name;
      bool senior = people[creator].senior;

       delete people[creator];
       assert(people[creator].age == 0);
       emit personDeleted(name, senior, owner);
   }
   function getCreator(uint index) public view onlyOwner returns(address){
       return creators[index];
   }
   function getBalance() public view onlyOwner returns(uint){
       return balance;
   }

}

@CryptoBuddha
I could not find costs modifier in your smart contract

Is it in Ownable.sol or Destroyable.sol?

Orelse you can also upload your code on GitHub and give us the link :slight_smile:

1 Like

Thanks @Taha, you were right, I was missing the modifier. I added it and know it works fine :slight_smile:

1 Like

I had to buy ether and I always get the same error “ALERT: Insufficient funds.”. I was up to 100 ether. What am I missing?

@dbeelow0323
Either you are using a different account you intend to or there might be enivornment issues or gas issues . Can you provide more info like which network you are using and on what condition you are getting this error?

Also remember to provide enough gas for your tranx

Thanks

1 Like

Does anyone else experience Ropsten Testnet being slower than a 100 year old Turtle?

@rostyslavdzhohola
Yeah, I did experience the same sometime, so I switch to other networks :slight_smile:

2 Likes

In the Deploy to Ropsten, Filip looks at the deployed contract in Etherscan and looks at the logged data. - Is there a different way to be able to view the data?
Also when adding a person, and not paying the required amount. Remix displays a gas error - but the real error is not paying for the contract. - so are there better logging mechanisms available to catch these errors?

1 Like

@iamchaoticcoder
In Ethereum there is only event to log transactional data. Events are trigger on successful execution of tranx on the EVM.
source: https://solidity.readthedocs.io/en/v0.5.3/contracts.html#events

For error handling you can use the following functions:

  • revert(): The revert() function can be used to flag an error and revert the current call.

  • assert(): The assert() function should only be used to test for internal errors, and to check invariants.

  • require(): The require() function should be used to ensure valid conditions, such as inputs, or contract state variables are met, or to validate return values from calls to external contracts.

Example for require and assert:

pragma solidity ^0.5.0;

contract Sharer {
    function sendHalf(address payable addr) public payable returns (uint balance) {
        require(msg.value % 2 == 0, "Even value required.");
        uint balanceBeforeTransfer = address(this).balance;
        addr.transfer(msg.value / 2);
        // Since transfer throws an exception on failure and
        // cannot call back here, there should be no way for us to
        // still have half of the money.
        assert(address(this).balance == balanceBeforeTransfer - msg.value / 2);
        return address(this).balance;
    }
}

Example for require and revert:

pragma solidity ^0.5.0;

contract VendingMachine {
    function buy(uint amount) public payable {
        if (amount > msg.value / 2 ether)
            revert("Not enough Ether provided.");
        // Alternative way to do it:
        require(
            amount <= msg.value / 2 ether,
            "Not enough Ether provided."
        );
        // Perform the purchase.
    }
}

source: https://solidity.readthedocs.io/en/v0.5.3/control-structures.html#error-handling-assert-require-revert-and-exceptions

1 Like

@filip I’m having trouble connecting to the Ropsten test network.
I took 1 ether from the faucet, but remix only connects to the mainnet, even after I cleared all session data in Brave.
Also manually connected from the ropsten network to remix.ethereum.org, but it still remains on main network.
Can you suggest something I can do?
image

This worked only ONCE for me. I got 0.5 ETH . followup attempts throws error:

Error: error sending coin; see log. [object Object]

@George
Thanks for reaching out!
Change the network in metamask, remix will auto detect the network

1 Like