0

I'm trying to understand how a private ethereum blockchain store data. I connect to a node through web3j API in java and send a transaction like:

                EthSendTransaction sendTrans = txManager.sendTransaction(DefaultGasProvider.GAS_PRICE
                    ,
                    DefaultGasProvider.GAS_LIMIT,
                    "0xae551c2ae4a15472c62c77cee07cf00467c19b9b",
                    txData,
                    BigInteger.ZERO);

where my txData is a hex number convert from a String "This is test Data". I see the pending transaction:

[{
blockHash: null,
blockNumber: null,
from: "0x6a30dd87fb4ce370c4fd4193e5b59b0cc4dc8daf",
gas: 9000000,
gasPrice: 4100000000,
hash: "0x772267cf882ddecdb2eefebeb2b611c109c14c2a1c413a9bfe7f96ec71508a9b",
input: "0xfcc7fd1e5153f1f6b2af143ebdc446815df610b67c9f550095d827d925eb0427",
nonce: 212,
r: "0xe33e228564c60fdba3b8cdf9af4ff814cab93746eb7f350230a3cc1b14cb1865",
s: "0x5630e0476543db3b729f66fe87ee50804d9522cf343c7e4e61b907307ed265ac",
to: "0xae551c2ae4a15472c62c77cee07cf00467c19b9b",
transactionIndex: null,
v: "0x1b",
value: 0

}]

where the input : "..." is the data that I want to store. However, after the block is mined, I use eth.getBlock("..."). I received:

{difficulty: 131072,extraData: "0xd683010914846765746886676f312e3135856c696e7578",
gasLimit:3144857017,
gasUsed: 23112,
hash: "0x7ed84ceae544a0a8237e75be62ec919b3e096e76bc558f965ae54d4b2b151cb7",
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", miner: "0x6a30dd87fb4ce370c4fd4193e5b59b0cc4dc8daf",
mixHash: "0x2ad17c7fe0638a87e47b2c9113c401c9c6bfc64bf7fefb3d3edbfdf0246e4742",
nonce: "0x6cfde534ed9015bd",
number: 319,
parentHash: "0xfa4030d2957a079314b10701daa332769430d78982e0467b03c5ab14ee5d25ed",
receiptsRoot: "0xe4d41217d0d481ec201d56b52c665b62cb73e7b4606cb189b31e09a3671d155e",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 675,
stateRoot: "0x58b99cab1ae04e204ef6a4339261d7d16a80f115e4a331ef30f66f0be19850d4",
timestamp: 1600853478,totalDifficulty: 41875200,transactions: ["0xcc8084be6574fe26a6045501c231557199c644e0add9ade3a6ba6202408fad56"],
transactionsRoot: "0xdae0f9a664d9fa2c48a344004c20b034e7d125395506eb3ce7d1c1e39aceb4bb",
uncles: []}

I'm confusing that how can I get back the string that I store in the block chain.

Regards,

1

Using eth_getBlock() will return the block data, not the specific tx data that you're looking for. You want the specific data from your tx. Since you have the tx hash ("0x7ed84ceae544a0a8237e75be62ec919b3e096e76bc558f965ae54d4b2b151cb7"), my assumption is that eth_getTransactionByHash() (wiki link) would be your best shot. If not that, you may want to use the RPC wiki to try and find a call that suits your needs.

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.