4

I have set up a private network with one node on Linux virtual machine and one is my local windows pc. I have done the peer adding. and I could see peer is added when I do a admin.peers on both the node. lets call two machines as machine A and machine B. I have created a contract which will store a number on machine A, here is the contract code (copied from internet) and deployment steps:

1) storeSrc

contract SimpleStorage {
    uint storedData;
    function set(uint x) {
        storedData = x;
    }
    function get() constant returns (uint retVal) {
        return storedData;
    }
}

2) storeCompiled

web3.eth.compile.solidity(storeSrc)

3) storeContract

web3.eth.contract(storeCompiled.SimpleStorage.info.abiDefinition);

4) store

storeContract.new({
    from:web3.eth.accounts[0],
    data: storeCompiled.SimpleStorage.code,
    gas: 300000},
    function(e, contract){
        if(!e) {
            if(!contract.address) {
                console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
            } else {
                console.log("Contract mined! Address: " + contract.address);
                console.log(contract);
            }
        }
    }
})

With following steps I could easily deploy the contract on machine A and was able to execute its as well.

Now since I have machine B as an added peer ideally I should be able to access this contract with its address. But in order to access the contract function I have to do following steps:

1) storeSrc

contract SimpleStorage {
    uint storedData;
    function set(uint x) { storedData = x; }
    function get() constant returns (uint retVal) { return storedData; }
}

2) storeCompiled

web3.eth.compile.solidity(storeSrc)

3)storeContract

web3.eth.contract(storeCompiled.SimpleStorage.info.abiDefinition);

4)store

storeContract.at("contract address")

So here are my questions:

Can I deploy this on a machine A without doing steps 1, 2, and 3?

Is there any way to avoid steps 1, 2, and 3 and directly access the contract using its address?

migrated from bitcoin.stackexchange.com Oct 6 '16 at 16:13

This question came from our site for Bitcoin crypto-currency enthusiasts.

2

Believe it or not, this is a problem that the public Ethereum network is facing. The solution that was initially planned ran into issues, and the moment people are manually passing around ABIs.

The ABI is just json, specifying the name of functions and their signatures. If you have some way of transferring that abiDefinition across the machines, you can jump straight to step 3. solc (the commandline compiler) will happily spit out the json for you. Even better, the ABI doesn't change as long as the signatures stay the same, so if your contract's functions aren't changing much, you won't have to rebuild the ABI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.