4

I deployed a contract yesterday which was mined and which was responding to calls. Today the contract "does not live" anymore. Do I need to redeploy? Is there a way to find addresses of contracts I deployed with a specific account?

3

The easiest way to find your contract is to checkout out the account that created the contract in a blockchain explorer.

For example, inspecting the account 0x5abfec25f74cd88437631a7731906932776356f9 will show you that it created the contract 0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae by its 4th transaction.

2

See How is the address of an Ethereum contract computed?

You may have been using a different network, like a testnet or tool. Or if you only interacted with the contract on mainnet for a brief moment after it was mined, it's possible there was a blockchain reorganization.

  • was deployed to testnet, and tried to call it again from testnet. – TMOTTM Jun 15 '16 at 21:20
1

If you used the testnet you can search for the contract's address (or the address used to broadcast it) using etherscan's testnet site. If it doesn't show up as a contract creation transaction then the contract was never deployed.

If it was deployed you need both the address of the contract and the ABI (for example this is the ABI for the DAO contract).

Using these you can open geth from anywhere and have a local instance of the contract with:

var abi = JSON.parse(contracts_abi_string);
var myContract = web3.eth.contract(abi).at(contractAddress); 

You can then interact with myContract.

  • It was deployed, i could call it. – TMOTTM Jun 16 '16 at 4:10
  • @TMOTTM Do you still have the ABI? In order to call it you'll need both the contract's address (which it sounds like you have) and the ABI. – toinetoine Jun 16 '16 at 4:16
  • No don't think so. I closed the client since then. In principle it was really just the greeter tutorial example. – TMOTTM Jun 16 '16 at 4:20
  • @TMOTTM If you recreate it locally and broadcast it make sure you save the ABI (should be a string of JSON for example this is the ABI for the DAO contract). Then you should be able to reopen geth from anywhere and have a local instance of the contract with: var myContract = web3.eth.contract(abi).at(contractAddress); where var abi = JSON.parse(contracts_abi_string);. You can then call your contracts methods on myContract. – toinetoine Jun 16 '16 at 4:31
  • ok cool. I'll consider it. – TMOTTM Jun 16 '16 at 4:42

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.