File Node

File Node Overview

The File node is a PIN path specifically designed for storing files. Through the File node, users can securely store files on the blockchain in the form of PINs, achieving decentralized file storage and management.

Data Format

The PIN content for storing files follows this format:

OP_FALSE
OP_IF
	metaid            
	create             
	/file/file-name-1.jpg     
	0                  
	OP_0               
	image/jpg;binary   
	<file data>        // Payload - Binary content of the file
OP_ENDIF

Here, <file data> contains the binary content of the file, and content-type specifies the file's data type (for example, image/jpg;binary indicates a JPEG image file).

File Node Path

The path for the File node uses /file as the base path and can further distinguish different files through file names or sub-paths. Through the File node path, users can easily locate and retrieve specific file PINs in the MetaID tree structure, thereby achieving effective organization and management of files.

File Referencing

In MetaID, file referencing is a fundamental business operation with critical importance. This feature allows users to reference existing on-chain file data in application protocols, enhancing data connectivity and user experience. To achieve this, we define a special file referencing rule.

File Referencing Format

When referencing a file in a sub-protocol, such as in the payload, we use the following format:

metafile://{pinid}

Here, PINID is the unique identifier of the file to be referenced. This format allows us to establish a reference link from the current protocol to a specific file.

Example

For example, posting with an attached file:

//Payload
{
	"content":"Hello bitcoin world!",
	"contentType":"text/plain",
	"createTime":1710741614716,
	"quoteTx":"",
	"attachment":[
		"metafile://{pinId}"
	]
}

The final on-chain content will be:

OP_FALSE
OP_IF
	metaid                           // Protocol identifier
	create                          // Operation type
	/protocols/simplebuzz         // Path
	0                                // Encryption type (0 means no encryption)
	0                                // Version
	application/json;utf-8              // Content-type
	{"content":"Hello bitcoin world!","contentType":"text/plain","createTime":1710741614716,"quoteTx":"","attachment":["metafile://{pinId}"]}       // Payload
OP_ENDIF

Last updated