Ethereum Asked by user3280964 on January 31, 2021
I successfully setup a private blockchain and created the “hello world” contract according to tutorial from etherium web site. One thing that I can’t figure out is how to find the contract later. I thought once the contract is mined, it becomes part of the blockchain forever. The documentation seems to imply permanence because it’s stressing how it’s good etiquette to clean up unused contracts by committing suicide on them. That’s why after I got this message, I thought the contract was permanently part of the blockchain:
Contract mined! address: ........
But after quiting geth and getting back in, I can’t find the contract anywhere (I lost it’s address). It seemed to last only during the single instance of when geth was running. What am I missing here? Do I have to register the contract for it to become permanent? Would I use the same technique on the real blockchain in order to get my code listed here?:
For those of you using Parity's trace_transaction call, the newly-created contract address appears in the trace.result.address
field. (And, as a side note, any self-destructed addresses appear in trace.action.address
while the address that receives the proceeds of the self-destruct appears at trace.action.refundAddress
.)
Answered by Thomas Jay Rush on January 31, 2021
When you are on MetaMask (this is a chrome extension) you can choose the option 'view on etherscan'. Here you can see all the Ethereum transactions.
In the To-address you will see: [Contract 0x........ Created]
Answered by Ivo van Leeuwen on January 31, 2021
You may use "web3.eth.getTransactionReceipt('{txn_id}')". It will give you the contract address as well as other information like block number etc.
Answered by Tarak Ram on January 31, 2021
You can use a filter to list all transaction from a given address.
var filter = eth.filter({fromBlock:0, toBlock:'latest', address: "0x.."});
filter.get(function (err, transactions) {
transactions.forEach(function (tx) {
var txInfo = eth.getTransactionReceipt(tx.transactionHash);
/* Here you have
txInfo.contractAddress;
txInfo.from;
txInfo.input;
*/
});
});
You can use an ether explorer like (https://github.com/etherparty/explorer) in your private testnet to look at the mined blocks. These particular explorer show only block info and transaction info. It uses angular and can be modified easily. But currently is somehow "limited".
Answered by Ismael on January 31, 2021
As jayD has already said, you can set a callback function to be notified when a contract is correctly created.
If you lost the moment, you can anyway retrieve the contract address later. In fact, the contract address is deterministically computed from the address of its creator and how many transactions the creator has sent.
See How is the address of an Ethereum contract computed? for more details.
Answered by Giuseppe Bertone on January 31, 2021
You're missing the contract address.
When sending a contract for the first time it will return the address to you as a Javascript callback that you said : " Contract mined! address: ........ "
But this is javascript.It will disapear when you closed the browser so you need to save the address beforehand and then call it back at will with :
var MyContract = web3.eth.contract(MyContract.abi);
var Instance = MyContract.at("address");
And you can the use Instance.thefunctionyouwant
You might be able to find the address by checking the last few transactions from your own address since as you said , it is saved forever, but you just don't know where it is. But as it's a test network i would suggest you to recreate the contract save the address and proceed as mentioned.
Answered by jayD on January 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP