Welcome to the thread about Contracts, Functions, State Variables, Getters & Setters in Ethereum. Here you can discuss everything about this chapter.
Remix is ran from browser only right?
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?
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.
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?
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 ?
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.
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.
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
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.
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?
sAll looks good. The output is in the console. Click the little arrow next to [vm] in the console to see all details.
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