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?
-
1Possible duplicate of How to find contract's address? – Ismael Jun 17 '16 at 05:30
3 Answers
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.
- 1,355
- 1
- 9
- 28
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.
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.
- 406
- 5
- 7
-
-
@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. – Antoine Dahan Jun 16 '16 at 04: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 04: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);wherevar abi = JSON.parse(contracts_abi_string);. You can then call your contracts methods onmyContract. – Antoine Dahan Jun 16 '16 at 04:31 -
-
Still, a local instance of the contract was not exactly what I was working for. I'm trying to deploy to the blockchain... – TMOTTM Jun 18 '16 at 08:30