0

0 down vote favorite

How can i retrieve the stored data from Block chain.?

I have inserted details in blockchain. When i type web3.eth.getBlock("latest"),

difficulty: 2,
extraData:     "0xd783010802846765746887676f312e372e31856c696e757800000000000000008f438649b8b4382ffd5630c744ccd6db346c8aabce2676a1fdbf752a2ce966b420bc17d8d0f5e31a1212ffad0ac36653e2df29cc14d6bb358b11512762676b0601",
gasLimit: 6382057,
gasUsed: 2653689,
hash:   "0xa3dca95fb581a30c1102732b685905ef10a454ec93e8d26171874360821c9055",
logsBloom:     "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 miner: "0x0000000000000000000000000000000000000000",
mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
nonce: "0x0000000000000000",
**number: 16,**
parentHash: "0xb9ea05ffc9908313d34a7db976e1b3017a7c9a200ace60445dc7f02d8a610795",
receiptsRoot: "0xfd5081c18fec1c7f65a80877425ac186d24713009a519e1659d2a4b2a8166c30",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 10494,
stateRoot: "0xe62d1d87c706b650f7e984c9688dc20d1b0a5dd4a7bf05e38e56ca2e63fbfc38",
 timestamp: 1520398284,
 totalDifficulty: 33,
 transactions: ["0x93f9be64f6f5d633298957374748677498dcb57f24ecd9a1c7cf02391e786338"],
  transactionsRoot: "0xc6c6abb3365c3413fcec7ab62a73ea84d76e17b8d8d2d7c83057d477d08ffaff",
uncles: []
}

its showing increase in number as and when i submit the data.

Is there any way to retrieve all the information stored in block chain. I do not want the hash and transaction details. I need the values i entered in the user interface page.

Kindly help!

  • What details have you inserted into blockchain? – medvedev1088 Mar 7 '18 at 7:03
  • FirstName, LAstName, UserID etc – Violet Mar 7 '18 at 9:20
  • Do you have the contract address and source code? – Teleporting Goat Mar 7 '18 at 9:46
  • I have the contract address. And source code as in the contract? – Violet Mar 7 '18 at 9:51
  • Could you explain how exactly did you put this information into blockchain? – Mikhail Vladimirov Apr 27 at 17:52
0

Maybe use something more high-level? Like remix, coupled with a local testrpc you can access data and call functions from your contract. (You can also access your contract if it's deployed in any blockchain, it doesn't need testrpc specifically)

If your contract is deployed, paste the source code in remix, compile it (compile tab, the start to compile) then access it by going in the run tab, paste the address of your contract in the At Address field, and the data and function should appear in the bottom.

Then you might need MetaMask paired with your account, once you have that choose Injected Web3 in the environment field.

  • Hello, i am running the code in the node. So not thru testrpc – Violet Mar 7 '18 at 9:20
  • @Violet On the testnet or the main network? – Teleporting Goat Mar 7 '18 at 9:23
  • i am using the ethereum private network. I am a beginner in this technology. Correct me if i am wrong. I have the used geth to connect to the network. – Violet Mar 7 '18 at 9:28
  • @Violet I'm not sure what you mean by "the private network". It's either the public network (main or test) or a private network (by definition not public and not unique). But I edited the answer to allow you to use your contact from remix. – Teleporting Goat Mar 7 '18 at 9:37
  • @TeleportingGoat private networks are not necessarily the public test networks. Private network being referred here most likely is his testing environment. – Ayushya Mar 7 '18 at 9:38
0

If you know the transaction hash, you can get the transaction. Transaction will also contain a section having input:. This will contain your required data, the data which was sent in that transaction

web3.eth.getTransaction("0x6556756757ae134....")

You will receive data in hex form. In order to view your data in string form, you need to convert it to string. You may use https://codebeautify.org/hex-string-converter

You need to look into how your environment is converting solidity data in hex form and transferring it to contract. This hex data includes information of number of parameters, values of parameters, and sometimes size of parameters(in case of dynamic data).

Example:

Lets take this example transaction: https://etherscan.io/tx/0x584738783f4e72f49f6c08c5b1f3b7e75c897a70b0a747795294b159aebe2a08

0x362132ad0000000000000000000000000000000000000000000000000000000000000d81000000000000000000000000000000000000000000000000000000000000006066326263376d3672326577000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003

This data can be decoded as follows:

0x362132ad

0000000000000000000000000000000000000000000000000000000000000d81 0000000000000000000000000000000000000000000000000000000000000060 66326263376d3672326577000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000005 0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000003 0000000000000000000000000000000000000000000000000000000000000001 0000000000000000000000000000000000000000000000000000000000000003

If you look at the input data, you will see the first 8 characters are methodID and then the data which was sent to that address.

  • That will contain the BlockHAsh , contract address and all right. I need the data i entered in the block chain like the F_name, L_name etc. How can i get that values? – Violet Mar 7 '18 at 9:22
  • @Violet Pardon me, you require function getTransaction. I have updated the answer. – Ayushya Mar 7 '18 at 9:35
  • web3.eth.getTransaction() ? Any parameters ? – Violet Mar 7 '18 at 9:43
  • Yes, the transaction hash should be passed as parameter. – Ayushya Mar 7 '18 at 9:48
  • I am getting the some binary values in "input" – Violet Mar 7 '18 at 9:50

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.