¿Cómo encontrar automáticamente el contrato?

Creé una red privada usando go-ethereum con 2 clientes que son máquinas virtuales (ubuntu 14.04).

En VM1, creé un contrato:

N1greeterSource ='contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) selfdestruct(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function changeMessage(string myMsg) returns (string){ greeting = myMsg; return myMsg; } function greet() returns (string) { return greeting; } }'
N1greeterCompiled = web3.eth.compile.solidity(N1greeterSource);
_greeting = "Hello world !";
N1greeterContract = web3.eth.contract(N1greeterCompiled.greeter.info.abiDefinition);
N1greeter = N1greeterContract.new(_greeting,{from:web3.eth.accounts[0], data: N1greeterCompiled.greeter.code, gas: 310000}, 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);
      }

    }
    else{
    console.log("Error:>>>>>>>>>>>>>");
    console.log(e);
    }

})

En VM2, veo contrato por:

N1greeter = eth.contract([{ constant: false, inputs: [], name: "kill", outputs: [], type: "function" }, { constant: false, inputs: [{ name: "myMsg", type: "string" }], name: "changeMessage", outputs: [{ name: "", type: "string" }], type: "function" }, { constant: false, inputs: [], name: "greet", outputs: [{ name: "", type: "string" }], type: "function" }, { inputs: [{ name: "_greeting", type: "string" }], type: "constructor" }] ).at("0x526e636021fbfef1584097690798145ff32be21a");

Todo está bien.

Pero, no sé cómo VM2 puede encontrar automáticamente el contrato. (busque la dirección y abi en VM1 para agregar este código: N1greeter = eth.contract(abi).at(address) )

Gracias.

Respuestas (1)

Puede probar el contrato de registro de nombres que se utiliza para asociar la dirección de su contrato con un nombre. En el caso de una red de prueba privada , deberá implementar el código de registrador en su red. Para hacer eso, primero deberá compilar el código de su repositorio git e implementarlo en su red tal como lo haría con cualquier otro contrato.

Para obtener más información sobre Registrar: ¿Qué es Global Registrar?

Otro enfoque para interactuar con un contrato es usar el Protocolo NatSpec. Para obtener más información al respecto, aquí está el enlace: NatSpec Github wiki .

Por favor, muéstrame cómo implementar el registrador. Estoy trabajando en la consola go-ethereum. Y es demasiado difícil encontrar "registrador"
He editado mi respuesta para incluir la respuesta a su consulta.
Intenté eliminar líneas y dividir el contenido de "GlobalRegistrar.sol". Luego sigo compilando por "web3.eth.compile.solidity" pero tiene algunos errores extraños. Muéstrame cómo puedo cargar "GlobalRegistrar.sol" desde la consola. Gracias