0xDEAFBEEF

Guide for Reconstructing Media: Chronophotograph

Summary: obtain the C source code and token's parameters values from Ethereum blockchain. Replace the variables in the C file where indicated. Compile and run the program,obtaining the raw output (BMP and WAV files). Encode the raw output to MP4,MP3 using ffmpeg.

Step 1: Obtain the C source code file and your token's parameters

Use a web3 client or etherscan.io to interact with the contract at https://etherscan.io/address/0xda1bf9b5de160cecde3f9304b187a2f5f5b83707.

Use the getTokenParams() function, passing your token ID.

Note the 'block_number', 'parent_id', 'epoch' parameter values that you will later need. 'codeLocation0' is the address of the transaction that contains the C source code. Visit that transaction address on etherscan, in this example it's https://etherscan.io/tx/0x1e9f43549f0d762746b8b6a1dd3d2f5caa4d2fd8462146f00affc855ae33f2fd Press 'Click to see More' and view the 'Input Data' field as UTF-8.

Copy and paste the C source code into a file on your computer named main.c.

Step 2: Replace the parameters variable with token's unique random hash

Near the top of the C source file, there is a function init_token_params():
void init_token_params() {
  // insert token ID...
  token_params.chronophotograph_token_id = 0;
  
  // ...and the parameters returned from smart                                                                                            // contract function getTokenParams(tokenID)
  //blocknumber the chronophotograph was minted 
  token_params.blocknumber = 0;

  //ID of parent noumenon token. 'parent_id' var in getTokenParams return vals
  token_params.noumenon_token_id = 0;

  //epoch
  token_params.epoch = 0;
}

Replace your token ID, and replace the indicated values with the 'p1','p2','p3' values previously read through getTokenParams(). For example:
void init_token_params() {
  // insert token ID...
  token_params.chronophotograph_token_id = 135;
  
  // ...and the parameters returned from smart                                                                                            // contract function getTokenParams(tokenID)
  //blocknumber the chronophotograph was minted 
  token_params.blocknumber = 17177993;

  //ID of parent noumenon token. 'parent_id' var in getTokenParams return vals
  token_params.noumenon_token_id = 17;

  //epoch
  token_params.epoch = 8;
}

Step 3: Install a C compiler for your platform.

Linux is the recommended platform, and GNU GCC is the recommended C compiler, available through default package managers. On Mac, you may be able to use Homebrew. On Windows, try GNU GCC binaries.

Step 4: Compile and run the program.

Code conforms to the ISO c99 standard. Only library dependency is C math library. Pass '-lm' to gcc. Assumes architecture is little endian (all Intel processors)

Compile and run. Optionally pass '-Ofast' flag to enable optimization (faster rendering).
$ gcc -Ofast main.c -lm && ./a.out

This will produce:
a. PGM(Portable gray map) 16bit grayscale, linear (no gamma) file named 'image.pgm'


PGM "Portable Gray Map" is an extremely simple file format for storing grayscale images. Specification here: https://netpbm.sourceforge.net/doc/pgm.html