Developer Documentation

Dibs

Be the first to register and claim your files. Dibs is a new way to manage your digital assets.

We are a file fingerprinting app and service that registers your claim on the public blockchain so that you can prove you had a file at a particular timestamp.

We allow you to directly create Dibs on the blockchain and then we will read them into this web interface. This allows you the most cost efficient way to create Dibs and make use of our web interface.

Example Code

You can use the following code to create a Dibs fingerprint. This will allow you to create a Dibs fingerprint programmatically.



import xrpl from 'xrpl';
import crypto from 'crypto';
import fs from 'fs';

const submitDibs = async (inputFile) => {
	if (!inputFile) {
		throw new Error('No file provided');
	}

	// read the file into a buffer
	const file = fs.readFileSync(inputFile);

	// create a random nonce
	const nonce = crypto.randomBytes(16).toString('hex');

	// create a hash of the file
	const hash = crypto.createHash('sha256').update(file).digest('hex');

	// create a new proof hash from the data nonce + file
	const proof = crypto
		.createHash('sha256')
		.update(nonce + file)
		.digest('hex');

	// this will be what's written to the blockchain
	const dibsData = {
		id: `sha256:${hash}`, // sha256:hash
		proof: `${nonce}:${proof}`, // nonce:proof
		contact: '', // no more than 140 characters
		description: '', // no more than 140 characters
		url: '',
		v: 0 // version
	};

	// remove any empty fields
	Object.keys(dibsData).forEach((key) => dibsData[key] === undefined && delete dibsData[key]);
	Object.keys(dibsData).forEach((key) => dibsData[key] === '' && delete dibsData[key]);

	const dibsDataSerialized = JSON.stringify(dibsData);
	console.log('dibsDataSerialized', dibsDataSerialized);

	console.log('connecting to xrpl');

	// connect to xrpl
	// const xrplClient = new xrpl.Client('wss://s.altnet.rippletest.net:51233');
	const xrplClient = new xrpl.Client('wss://xrplcluster.com'); // live

	// make sure we're connected
	await xrplClient.connect();

	// TODO: setup your wallet etc

	// create a dibs transaction
	const memos = [
		{
			Memo: {
				MemoType: xrpl.convertStringToHex('dibs').toUpperCase(),
				MemoData: xrpl.convertStringToHex(dibsDataSerialized).toUpperCase(),
				MemoFormat: xrpl.convertStringToHex('application/json').toUpperCase()
			}
		}
	];

	const wallet = xrpl.Wallet.fromSeed('sXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

	const FIXED_DIBS_ADDRESS = 'rEeMgaXgTvBryoBZdFj9NC5J66JmREcdLf'; // the address of the directory, do not change

	const amount = 1; // 1 xrp required to submit a dibs to the directory

	const tx = {
		TransactionType: 'Payment',
		Account: wallet.address,
		Destination: FIXED_DIBS_ADDRESS,
		Amount: xrpl.xrpToDrops(amount),
		Memos: memos
	};

	const prepared = await xrplClient.autofill(tx);
	const signed = wallet.sign(prepared);

	const resultXrpl = await xrplClient.submitAndWait(signed.tx_blob);

	// see if it completed ok
	if (resultXrpl.result.meta.TransactionResult !== 'tesSUCCESS') {
		// ok = false;
		console.log('Error submitting transaction', resultXrpl);
	}

	await xrplClient.disconnect();
};

// submit the dibs
submitDibs('example.txt');
			

Use Cases

You might be interested in creating fingerprints in bulk. This will enable you to create a large number of fingerprints programmatically, without having to use the web interface. Instead of paying via credit card, your payments occur via sending XRP payments to the Dibs directory.

Need help?