9 ms·
Exporting image assets from ethereum smart contract with solidity
- deleted 6y ago[deleted]
- raidicy 6y agoWhat about storing a base64 string and decoding it in the client? Would an arbitrary base64 string fit in a 256 variable?
- jstanley 6y agoThe amount of image data you can fit in (I assume) 256 bytes is pretty small. That's enough for an uncompressed 8-bit 16x16 pixel bitmap with no header. And you only get 3/4 of that amount of information if it's base64'd. With compression you can do better, but 256 bytes is not going to get you anywhere near the kind of high-resolution artwork that people seem to be using NFTs for.
- seoaeu 6y agoImage compression will get you way further, but even then you'd probably need 10x the space for anything remotely reasonable
- Animats 6y agoHow much "gas" does it cost to store data in the Etherium blockchain? The entire Etherium blockchain is about 180 GB.
- dezmou 6y agoThe image data is not stored, only the seed needed to generate the bitmap, the image generation is done by a gasless view function when needed
- jstanley 6y agoThat doesn't really help in the general case. If you can compress arbitrary images down to a single small seed, then you have the best image compression algorithm in the world. The applications of good image compression are much broader than NFTs. It looks like this project doesn't actually store arbitrary pictures.
- dezmou 6y agothis is why this approach is reserved to on-chain generated NFTs
- babyshake 6y agoWhat about the types of sprites that you would find in an Atari 2600 or similar system? Would it be even remotely practical to store these on the Ethereum blockchain?
- dezmou 6y agoA 64x64 monochrome bitmap would weight 512 bytes, still very expensive to store on blockchain
- chrisco255 6y agoNah, it's not that prohibitive. Your standard Ethereum smart contract has at least a dozen variables stored at any time. About a year ago it was roughly $13 per KB. That price has probably doubled since then.
- vmception 6y agoThe real answer is that you have to pay attention to the gas limit per block, which is pretty high now On the Ethereum EVM it is 12,000,000 ether gwei. Most blocks are full. If you are willing to pay 12,000,000 ether gwei at competitive gas prices, it will get mined. For an image application you can probably use as many blocks as you want to create and store a larger image. As blocks are already full, this wont change anything, some people will get priced out for the time being or they pay higher gas price, miners get paid 12,000,000 ether gwei * gas price either way. So gas prices right now are like 135 gwei. 12,000,000 ether gwei is 0.012 ether. 0.012 * 135 = 1.62 ether @ $1,704 per ether = $2760 cost if you want to fill up an entire block Binance Smart Chain EVM has 30,000,000 binance gwei gas limit. And the binance token is much cheaper to begin with at the moment. and there are other EVMs, you can find the EVM you want to use. Ethereum mainnet EVM has the highest number of nodes to store it though. Its economical if you can sell it for a higher price. No different from any other art trade, artist can take the risk or a studio can front capital.
- vmception 6y agoSidenote: you should really learn about the EVM and be able to synthesize the same answers as I did this is unrelated to being a “blockchain skeptic”, a “no-coiner”, a “bitcoin only, Ethereum is too centralized, dont mention any other distributed ledger around me” person, or anything else The EVM (Ethereum Virtual Machine) concept is as important to be up to speed on as the JVM (Java Virtual Machine) concept
- c-cube 6y agoSidenote: you should really learn about homeopathic dilution and how to synthesize the same cancer drug as I did. This is unrelated to being a "homeopathy sceptic", a "no-diluter" person, or anything else. --- Really? If you think blockchains are stupid, why should you learn about the details of how exactly the pollution happens and how much real money is used to power each transaction?
- vmception 6y agoBecause I think ad retargeting conglomerates are stupid too but they still use the JVM and I’ll work for san organization or project involved in that which uses Java
- kfichter 6y ago20,000 gas for 32 bytes of data if you want it to be accessible by other smart contracts. 16 gas per non-zero byte (4 gas per zero byte) of "transaction input data," which is accessible to clients off-chain but is not accessible to smart contracts.
- Canada 6y agoYou are way off. The entire Ethereum blockchain is approximately 6 TB. Even a pruned version is over 400 GB. There is no specific cost for storage, only gas for execution. For dynamic storage the SSTORE operation stores a word (256 bit). It costs 20,000 gas when the value is set from zero to non-zero, 5,000 gas when the value is set from non-zero to non-zero, and it provides a refund of 15,000 when the value is set from non-zero to zero. This is the only way to make data readable by contracts and thus light clients. There is also the option of storing as code, which cannot be updated. There's the 32,000 gas paid for the CREATE and then 200 gas per byte for the code. This is much cheaper at 6,400 gas per 32 bytes. So deploying a 128 byte string assuming a gas price of 100 GWEI and $1700 ETH: 32,000 + (6,400 * 4) = 57,600 gas 57,600 gas * 0.000000001 ETH (1 gwei) * 100 gwei * $1700 = $9.79 This would just store bits, it wouldn't be a valid contract you could actually call. Or you could write your data as the parameters to a contract call at a price of 4 gas per zero and 16 gas per non-zero.. You would be able to read data stored this way off etherscan. I'm not including the base 21,000 gas you have to pay for any transaction.
- saurik 6y ago> You are way off. The entire Ethereum blockchain is approximately 6 TB. Even a pruned version is over 400 GB. Your 6TB figure includes "store every single historical past state of the system", which is going "above and beyond": it is something that you never need to do for either correctness or operation of the system, whether as a user or as a miner... the only people who use archive nodes are people who are trying to more easily step-by-step debug old transactions.
- Canada 6y agoYou need a full fat DB if you want to be able to accurately detect transactions more than 2 days old. You need to do it if you care about more than just the current balance and don't want to rely on a centralized middleman such as etherscan.
- saurik 6y agoI don't understand what you mean by this; you do not need an archival node to either pull transaction receipts or to request transaction logs: you only need an archival node if you want access to all of the starting storage states of all past blocks, which you effectively never need (except for debugging). Notably: a "full node" is not an "archive node", and will not need more than the 400GB of space.
- ghayes 6y agoThe other common approach here (for non-generative images) is to store the Sha3 hash of an image and then simply require that someone, somewhere has the actual data. You could also pass the image as a LOG message which is significantly cheaper (3 gas per byte, versus 20,000 gas per 32-bytes to store data) which means if you can read older chain blocks, you can ensure you have the underlying data.
- choxi 6y agoWould this be equivalent to storing the encryption key on the blockchain such that only people with an NFT have the key, and can decrypt the image (wherever the encrypted image is stored)?
- verdverm 6y agoNo, storing the SHA3 means that if you have the image, you can verify that it has not changed
- nmaleki 6y agoFew questions, By "actual data" I'm assuming you mean the image itself? What does a request for the actual data look like, because it is my understanding the actual data wouldn't be stored on the blockchain? The LOG message is built into the Ethereum blockchain?
- xrd 6y agoIsn't this an interesting example where you could do fun things by writing the image data into a cheap blockchain where the cost isn't high (making it immutable) but then associating it with the SHA or encrypted private key on the blockchain where the item is sold? The art goes on the dogecoin, the purchase happens on ethereum.
- chrisco255 6y agoTypically people will store it somewhere (S3 or otherwise) and generate an IPFS hash of the file and write the hash to the NFT. Doge is just a Bitcoin fork and can't store data any more easily than Ethereum. File storage protocols exist such as Sia and Filecoin, that are more appropriate for decentralized storage.