Creating a contract,watching for events,sending transaction to contracts

Is it possible to Create a contract,watching for events,sending transaction to contracts without downloading not even single block.
Without syncing with public ethereum network can one create contracts or send transactions

Comments

  • subhodshamboorsubhodshamboor Member Posts: 5
    Answer please.
  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    You need an account from which to deploy the contract so you need access to a fully synchronised node. That node might be a client or there are some web wallets that might provide function to deploy contracts.

    Once deployed, contracts cannot launch themselves automatically and need some outside intervention to call them.
  • subhodshamboorsubhodshamboor Member Posts: 5
    edited June 2016
    consider a example where i have deployed a contract with a function which actually modifies a boolean variable.assume that at first it is initialized with true value.later i will send transaction to make that boolean variable to false.so at any time when i can call a function of that contract to retrieve that variable value is it returns the latest value

    in my case i am using geth and web3 module in nodejs.
    geth rpc running .without downloading any blocks can i do all this manipultions.
    Post edited by o0ragman0o on
  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    @subhodshamboor So something like:
    contract Bool
    {
    bool isTrue;
    function Bool() {
    isTrue = true;
    function setIsTrue(bool _isTrue) {
    isTrue = _isTrue;
    }
    }
    ABI functions are:
    Bool()
    isTrue() // implicit getter
    setIsTrue(val)
    If you are running geth rpc then you are sync'ing the blockchain. As for connecting your JS to a remote node, the web3.js wiki has this providers example:
    if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
    } else {
    // set the provider you want from Web3.providers
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
    }

  • subhodshamboorsubhodshamboor Member Posts: 5
    without running rpc is there any way ,so that i can directly interact with blockchain from my nodejs code
  • o0ragman0oo0ragman0o Member, Moderator Posts: 1,291 mod
    @subhodshamboor The ethereumjs project is a JS Ethereum client if that's more of what you're looking for. Other than that I'm not really follow what you're trying to ask for
  • SuManiSuMani Member Posts: 1
    Yes.

    The following does from node.js.
    Change the ABI for the "nodeGreet".
    Change the function name : nodeGreet.greet() with your function name.

    var Web3 = require('web3');
    var web3One = new Web3();


    web3One.setProvider(new web3One.providers.HttpProvider('http://localhost:8545'));

    var coinbase = web3One.eth.coinbase;
    var balance = web3One.eth.getBalance(coinbase);

    console.log('node 1 -> coinbase : ',coinbase);
    console.log('node 1 -> balance : ',balance);



    var nodeGreet = web3One.eth.contract([{ constant: false, inputs: [], name: "kill", outputs: [], type: "function" }, { constant: true, inputs: [], name: "greet", outputs: [{ name: "", type: "
    string" }], type: "function" }, { inputs: [{ name: "_greeting", type: "string" }], type: "constructor" }]).at("0x40dd6b141aa0b9e02e504683de5fb56b7b8eb579");

    console.log(nodeGreet.greet());


Sign In or Register to comment.