Essential TKN dataset and onchain operations.
# download repo
git clone https://github.com/tickerdao/tkn-cli.git
cd tkn-cli
# build and setup tkn command
npm install
npm run build && npm link
Some commands require Pinata to upload files to IPFS. Please sign up for an account at Pinata Cloud to get your API key and secret.
Set them as environment variables using the below commands.
export PINATA_API_KEY=<your pinata api key>
export PINATA_SECRET_API_KEY=<your pinata api secret>
Please refer to dataset1.json
and dataset2.json
in the data
folder for examples of the standard data structure. Commands which take a dataset file as an input will expect a json file with a dataset field and/or a tree field.
Please refer to dai-proofs.json
and dai-website-proof.json
in the data
folder for example files which the validate
command can work with. fetch
command saves files in this format.
Generates command takes a standard dataset file as an input to generate a merkle tree. Generate command can either read a local file or read a file from IPFS using its content hash.
tkn generate --file ./data/dataset1.json
Dataset file can be downloaded from IPFS using its content hash with the download
command.
Reads dataset
field from the JSON file to generate a merkle tree of all the fields and adds a tree
field with the information back to the JSON file. Merkle tree information is generated by the Openzeppelin merkle library.
Upload uses Pinata to upload the given local file to IPFS.
export PINATA_API_KEY="..."
export PINATA_SECRET_API_KEY="..."
tkn upload --file ./data/dataset1.json
Uploads the given file to IPFS. Command requires PINATA_API_KEY
and PINATA_SECRET_API_KEY
to be set as environment variables.
tkn download --ipfs <content hash> --file <path to download file>
Downloads a file from IPFS using its content hash value from IPFS to the filepath specified. Does not overwrite and will fail if a file already exists at the specified path. Command uses the Cloudflare IPFS gateway to download the file which does not need any setup.
Fetch the values and proofs for all fields or a single field of a token symbol.
# single field on a symbol
tkn fetch --token DAI --field token_address --file ./data/dataset1.json
# all fields on a symbol
tkn fetch --token DAI --file ./data/dataset1.json
We can save the values and proofs to a file for later use.
tkn fetch --token DAI --field token_address --file ./data/dataset1.json --save ./data/proofs/dai-proof1.json
Dataset file can be downloaded from IPFS using download
.
Proof file generated in this step can be uploaded to IPFS using upload
.
Validate the given value(s) and proof(s) of fields against a merkle root value.
tkn validate --file ./data/dai-proofs.json --root 0x00912eb6bc80ceaf643e95ff1558f5dd6d93eeabf0913f5e65d181970ad57bf5
tkn validate --file ./data/dai-website-proof.json --root 0x00912eb6bc80ceaf643e95ff1558f5dd6d93eeabf0913f5e65d181970ad57bf5
Proof files present on IPFS can be downloaded locally using download
.