Contracts, Functions, State Variables, Getters & Setters

Welcome to the thread about Contracts, Functions, State Variables, Getters & Setters in Ethereum. Here you can discuss everything about this chapter.

2 Likes

Remix is ran from browser only right?

Yes, correct. https://remix.ethereum.org

2 Likes

Hi, I have just started using remix but there was no “CREATE” button in my RUN tab, only a “DEPLOY” button. Is there something I am doing wrong here?

2 Likes

In older versions of remix it used to be called the “Create” button but has now changed to “Deploy” so what you’re doing is fine.

6 Likes

Congratulations on making it to the blockchain everyone! It’s time to carve our name into it’s immutable history!

pragma solidity 0.4.0;
contract Name {
   string name;
   function setName(string _name){
       name = _name;
   }
   function getName() view returns (string){
       return name;
   }
}

Now how to push those pesky strings into an array of names?

1 Like
pragma solidity ^0.4.0;

contract Name{
   string name;
   uint age;
   function setName(string _name){
       name = _name;
   }
   function setAge(uint _age){
       age = _age;
   }
  function getName() view returns (string){
      return name;
  }
  function getAge() view returns (uint){
      return age;
  }
}

I assume that’s normal to not understand everything in types documentations at this stage ? :slight_smile:

1 Like

Yes, absolutely. You will learn as you progress through the course. But it is always good to learn to use the documentation to search for answers to potential questions that arise.

1 Like

I wonder how many people have made it this far… I’m really digging this course and only had pretty minimal prior knowledge. It would probably be a good idea for me to review C++ as I move through this section. Great work @filip and @ivan! I am super happy to have purchased this course.

5 Likes

Hello Guys!, When i try to run setOutput function, this happen: SyntaxError: Unexpected token G in JSON at position 1.

CODE:

contract Dog {

string output = "Doggie";

function bark() view public returns (string)  {
   
   return output; 
    
}

function  setOutput  (string _output) public  {
    
    output = _output;
}

}

It happend with my assigment code too and in the stackoverflow page i did not see a familiar help to solve it :frowning:

I have problem with the strings variables. Any Help? :wink:

Make sure that you input the value into the input box with quotes if it’s a string.

So if you want to change the output to test, you have to type “test” into the input box in remix. With the quotes.

3 Likes

I dont get any output after running bark . There is no button for details. I can not find solution. Maybe I should change something in settings?

s

2 Likes

All looks good. The output is in the console. Click the little arrow next to [vm] in the console to see all details.

1 Like

Evening all. Here’s my code for this:

pragma solidity ^0.4.0;

contract myNewContract {
    
    string name;
    uint age;
    
    function setName(string _newName) {
        name = _newName;
    }
    
    function setAge(uint _newAge) {
        age = _newAge;
    }
    
    function getName() view returns(string) {
        return name;
    }
    
    function getAge() view returns(uint) {
        return age;
    }
}

Hi All,

Here is my code:

pragma solidity ^0.4.0;

contract Person{
    string name;
    uint age;
    function getName() public view returns(string) {
        return name;
    }
    
    function setName(string _name) public {
        name = _name;
    }
    
    function getAge() public view returns(uint) {
        return age;
    }
    
    function setAge(uint _age) public {
        age = _age;
    }
    
}

I test in this solidity compiler ,test ok
http://remix.ethereum.org/#optimize=false&version=soljson-v0.4.23+commit.124ca40d.js

// 定義是用什麼Solidity的版本編譯
pragma solidity ^0.4.23;

contract Dog {

  string output = "Doggie";

   function bark() view public returns (string)  {
   
     return output; 
    
   }

   function  setOutput  (string _output) public  {
    
      output = _output;
   }
}
// 定義是用什麼Solidity的版本編譯
pragma solidity ^0.4.23;

//定義智能合約的名稱
contract GivMeMoney{
    
    uint output = 989;  //變數 string ,int ,uint, bool ..
    
    function wallet() view returns (uint) {  //函數 輸入 輸出
        return output;
    }
    function giveme(uint _output) {
        output = _output;
    } 
}

Here is my code ,test ok
http://remix.ethereum.org/#optimize=false&version=soljson-v0.4.23+commit.124ca40d.js

1 Like