Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    prasadgudla
    @prasadgudla
    once renamed you have to call truff compile not truffle compile
    If while running truff migrate error you get then we have to add entries to truffle.js file , which is located near contract folder.
    module.exports = {
    networks: {
    development: {
    host: "localhost",
    port: 8545,
    network_id: "*" // Match any network id
    }
    }
    };
    Gopal Panda
    @pandagopal
    Good Source if we are developing
    Gopal Panda
    @pandagopal
    Ok i have been facing this issue , unable to run the command truffle migrate , in truffle console i am getting Error: HelloWorld has not been deployed to detected network (network/artifact mismatch)
    Solution is truffle migrate --reset
    image.png
    Awesome video for Smart contracts.
    They have Playlist which is 24 part video an excellent tutorial
    prasadgudla
    @prasadgudla
    We can issue multiple commands using && truffle compile && truffle migrate
    To display the list of test account issue the command: web3.eth.accounts
    to understand how real coding is done
    Gopal Panda
    @pandagopal
    to find ether transaction go to https://live.ether.camp/
    Gopal Panda
    @pandagopal
    There is some design patterns in this area, which can be very help while doing full fledged development , it can be found here https://github.com/pandagopal/docs.erisindustries.com/tree/master/tutorials/solidity
    Gopal Panda
    @pandagopal
    If you want to know live how many nodes are running and where in the world , both for Mainnet and Testnet go to https://ethernodes.org/network/1
    If you are thinking of sending contract to real Ethereum Network. then download "Geth" client https://geth.ethereum.org/downloads/
    Gopal Panda
    @pandagopal
    A Sample DApp is here you can see in action https://github.com/Vishwas1/voting-daap-2017
    Gopal Panda
    @pandagopal
    What's the cost of the gas https://ethgasstation.info/
    ndr-power
    @ndr-power
    Hello
    The problem is in connecting
    to the network
    It always stucks at downloading blockchain
    And trying to find peers
    Idk what to do
    I was trying to start for over 1 week
    Gopal Panda
    @pandagopal

    @prasadgudla pragma solidity ^0.4.4;

    contract HelloWorld{
    function SayHello() returns(string){
    return("Hello Gopal how are you? your First Contract !");
    }

    }

    Gopal Panda
    @pandagopal
    1_intial_Migration.js file data for helloworld contract

    var Migrations = artifacts.require("./Migrations.sol");
    var helloworld = artifacts.require("./helloworld.sol");

    module.exports = function(deployer) {
    deployer.deploy(Migrations);
    deployer.deploy(helloworld);
    };

    Gopal Panda
    @pandagopal
    Which talks about ICO(Initial coin Offering)
    Gopal Panda
    @pandagopal
    Found a tool which creates ICO page , this tool will generate file contract file which we can see it and learn how an ICO contract is written professionally
    Prakash Kavi
    @prakash-kavi
    Nice
    Gopal Panda
    @pandagopal
    And the video on how to use this tool is here https://www.youtube.com/watch?v=Hvs1gICcXGU
    Gopal Panda
    @pandagopal
    This is the baseline for reference https://github.com/OpenZeppelin/zeppelin-solidity
    Gopal Panda
    @pandagopal
    Those who wants to learn for free all the basics you can do it here https://coursetro.com/courses/20/Developing-Ethereum-Smart-Contracts-for-Beginners
    Gopal Panda
    @pandagopal
    Once contract is deployed in Ethereum all you get is an Address where your bytecode lives, now who ever knows your Address can also make use of it, how do we stop that, it's like who ever deployed the Contract only they should be able to call it.
    Gopal Panda
    @pandagopal

    pragma solidity ^0.4.18;

    contract Coursetro {

    string fName;
    uint age;
    
    event Instructor(
       string name,
       uint age
    );
    
    function setInstructor(string _fName, uint _age) public {
       fName = _fName;
       age = _age;
       Instructor(_fName, _age);
    }
    
    function getInstructor() view public returns (string, uint) {
       return (fName, age);
    }

    }
    Creating a Modifier

    Function modifiers in smart contracts can be used for a variety of purposes. For our purpose, we're going to create a modifier that will only allow the owner of the contract to set the instructor name and age through the setInstructor() function.

    To do this, we first have to define a new variable as a type of address:

    contract Coursetro {

    string fName;
    uint age;
    address owner;     // Add this
    
    // Other stuff removed for brevity

    Next, we have to call the constructor method in order to set the owner variable to the address that created the contract.

    The constructor function is called only once, which is when the contract is first created:

    contract Coursetro {

    string fName;
    uint age;
    address owner;
    
    function Coursetro() public {     // Add this constructor
        owner = msg.sender;
    }

    Great, now that we know owner contains the contract creator's address, let's create a modifier beneath the constructor:

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    So, to create a modifier, you first start by stating modifier and the name of the modifier. In our case, it will be onlyOwner which can be used multiple times as a modifier depending on your needs.

    Note: Modifiers can also receive arguments, ie: modifier name(arg1)

    Inside of our modifier, we're saying require() which is a way of saying, "if the condition is not true, throw an exception".

    If the condition is true, _; on the line beneath is where the function body is placed. In other words, the function will be executed.

    Using the Modifier

    We've created a modifier, now what? Well, we can use it in any function where we only want the smart contract creator to have access.

    Let's add it to the setInstructor() function:

    function setInstructor(string _fName, uint _age) onlyOwner public {
       fName = _fName;
       age = _age;
       Instructor(_fName, _age);
    }

    Notice onlyOwner is specified just after the arguments of the function. That's all it takes!

    If you want to give it a go in the Remix IDE, click the Create button to create the contract. Then, specify "Gary", 44 in the setInstructor function textfield on the right of the IDE and click on the function name to set it.

    It should work, and to verify, click getInstructor.

    Now, try changing the Account dropdown at the top to a different account than the one used to create the smart contract and repeat the process above.

    You'll notice it won't work this time, the debugger will throw an error.

    Gopal Panda
    @pandagopal
    To interact with outside database, one have to use Oracle service call oraclize additional details can be found here https://docs.oraclize.it/#background
    Gopal Panda
    @pandagopal
    function myFunction() <visibility specifier> returns (bool) {
    return true;
    }
    Global Variables
    block.blockhash(uint blockNumber) returns (bytes32): hash of the given block - only works for 256 most recent blocks
    block.coinbase (address): current block miner’s address
    block.difficulty (uint): current block difficulty
    block.gaslimit (uint): current block gaslimit
    block.number (uint): current block number
    block.timestamp (uint): current block timestamp
    msg.data (bytes): complete calldata
    msg.gas (uint): remaining gas
    msg.sender (address): sender of the message (current call)
    msg.value (uint): number of wei sent with the message
    now (uint): current block timestamp (alias for block.timestamp)
    tx.gasprice (uint): gas price of the transaction
    tx.origin (address): sender of the transaction (full call chain)
    assert(bool condition): abort execution and revert state changes if condition is false (use for internal error)
    require(bool condition): abort execution and revert state changes if condition is false (use for malformed input or error in external component)
    revert(): abort execution and revert state changes

    Modifiers
    pure for functions: Disallows modification or access of state - this is not enforced yet.
    view for functions: Disallows modification of state - this is not enforced yet.
    payable for functions: Allows them to receive Ether together with a call.
    constant for state variables: Disallows assignment (except initialisation), does not occupy storage slot.
    constant for functions: Same as view.
    anonymous for events: Does not store event signature as topic.
    indexed for event parameters: Stores the parameter as topic.
    Reserved Keywords
    These keywords are reserved in Solidity. They might become part of the syntax in the future:

    abstract, after, case, catch, default, final, in, inline, let, match, null, of, relocatable, static, switch, try, type, typeof.

    Jorge André Alves
    @jorgealves
    Hey guys! i'm Jorge and I started to learn blockchain and solidity last month! Do you have any tip or 'recipe' so I can dig more in solidity ?