40

I want to store pdf hash in blockchain I already read this post What are some proposed ways of storing data in Ethereum? But I'm beginner in this domain and I don't understand... Is it possible to store data (hash in my case) in Ethereum?

How many cost to store data in Ethereum? And how can I do this with python or an other language?

5 Answers 5

30

You can store data in the blockchain:

  1. In a special place on the blockchain reserved for contract data
  2. In a special place on the blockchain reserved for transaction input data

To store your data in a special place 1 you'll need to create a contract and deploy it on the blockchain.

To store your data in a special place 2 you'll need to send someone a transaction and include your data in it.

Before you you can interact with the blockchain you will need to get access to the web3 object. There are multiple ways of doing so. I'd suggest you installing MetaMask plugin for Chrome browser. After you install it, you will have access to web3 object. The ways of interacting with web3 object can be found here (web3 api documentation)

Now that you've installed MetaMask plugin. Choose Morden testnet in the configs. Now you can use solidity browser compiler. Try to compile and deploy a simple contract there:

contract A {
    uint x = 255;
}

You will need some ether in your account(MetaMask provided account) to deploy contracts. Go to https://morden.ether.camp/ and get 5 testnet ether for free.

10
  • And after I install web3, could I store data in a special place 1?
    – wxcvbn
    Commented Aug 9, 2016 at 12:15
  • @wxcvbn, I updated my response, check it out, feel free to ask
    – manidos
    Commented Aug 9, 2016 at 12:26
  • Thank a lot for your answer! Can I insert several hash in one contract? Or is it possible to open an existing contract and add a hash? I need some ether for each contract created or for each data insert in contract?
    – wxcvbn
    Commented Aug 9, 2016 at 12:36
  • @wxcvbn,You can insert as many hashes into a contract storage as you want. The more data your contract is supposed to hold, the more you will pay for its creation. If you want to open a contract and invoke a function in it you may pay or may not pay ether. If this function modifies anything on the blockchain, for example, stores some value provided by you, then you pay ether. So, yeah, you pay for each data insert. To open an existing contract you will need to know its address and **abi**(it's like a description of the code inside a contract).
    – manidos
    Commented Aug 9, 2016 at 12:50
  • So juste I need to create MetaMask account and add ether? I'm a little lost, what do I do first? download Ethereum? Or MetaMask?
    – wxcvbn
    Commented Aug 9, 2016 at 13:31
11

You can store data in the input data field of a transaction.

In this answer I outline how much data can be stored in the input data of a transaction.

At the time of writing it is approximately 98,225 non-zero bytes of data. This costs between $1.05 and $12.66 depending on the gas price that you set.

This post outlines how this data storage has been taken advantage of to allow users to store images on the blockchain. Note - NSFW.

1
  • Hi there. I tried something similar with Metamask. See ethereum.stackexchange.com/questions/127889/…. But apparently it doesn't work with Metamask and I would need to create a special smart contract just for that. Do you confirm that I cannot do this with something like Metamask ? Commented Jun 8, 2022 at 16:34
1

I wouldn't recommend storing data in Ethereum if its sensitive in nature, the reason being anyone can access data in Ethereum transactions with ease. You can find more on this here. Any sensitive data should either be stored off-chain or carefully encrypted based on SWC-136.

0

You can also check out EthAir Balloons npm package which is a JS library offerin a model level of abstraction above smart contracts, allowing you to save data on ethereum network without writing a Solidity smart contract

0

Just use a 160 bit / 40 hex digits hash (e.g. RIPEMD-160) of your pdf and use it as the target address of a simple transaction with almost 0 Eth. This is the prove, you own this file at this moment.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Nov 19, 2021 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.