0

We have installed truffle to two nodes and we initialize our private blockchain with: $geth --datadir node init genesis.json

Then we run geth on both nodes with: $geth --datadir node --nodiscover -rpc --rpcapi="db,eth,net,web3,personal,web3" console

We are using same genesis.json files.

After that, we migrate contract on both nodes, and we are using:

ContractName.deployed() var contract = ContractName.at('address')

Then in the two nodes we run function like that:

contract.then(function(cI){cI.addValue().then(function(v){console.log(v)})})

However, after a node run the contract, other node don't run on the same contract, I mean, if we want to show the values added to an array, every node shows it's own array, not a single one.

Are we running contracts in two nodes in a wrong way?

Edit: Solved the problem. We have migrated smart contract on a single node, then in all nodes, we simply created a contract instance with

var contract = ContractName.at('address')

0

As you say it works when you deploy in a node and access the contracts from other nodes using ContractName.at(address).

An alternative is to copy those artifact files generated by truffle in the build/ directory to the other nodes. The you can reference the contracts with ContractName.deployed().

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.