Hedera File Service API

Get started View docs

Manage and verify files

Use the Hedera File Service to anchor external data to the transparent public ledger. Examples of external data could be a hash to a document or database. The file service is purpose built to manage credentials and to verify that data existed at a certain time with a fair timestamp.

Secure files, transparent details

Revocation service
Easily and quickly prove that credentials and other documents have not been revoked by the issuing party by verifying signatures.
Anchor files
A file can contain the hash of an external document or database. Letting you cost-effectively manage larger files stored on a side-ledger, IPFS, or centralized provider.
Secure storage
Hedera distributes your file to each node on the network to assure your file is secure and highly available.

File Service API and network features

Transparent transactions

Collaborate between parties with shared data records for more efficient data reconciliation and processes using verified signatures and consensus timestamps.

Define ownership

Manage a write access control list to define ownership of files with advanced key structures.

Revoke claims

When granting access to someone, you often need to revoke access, too; like an employee's access to a building. Accounts on Hedera can have livehashes to establish an instantly verifiable and revokable claim.

CONTROLLED MUTABILITY

A file can be deleted by its owner, e.g. to comply with regulatory requirements, and afterwards, a state proof can prove to third parties that it was deleted.

Point off-ledger

Cost effectively manage large documents by creating a file containing a hash that acts as a pointer to an off-ledger document stored in the cloud.

Globally distributed

Hedera File Service distributes your file to each node in the Hedera network, ensuring high availability and reliability.

Store and read files

The Hedera File Service API provides the ability to manage files and their content, control access, and verify their owners.

Function

Add file
  • Add file
  • Query file
  • Delete file

//Create a file owned by your account

var tx = new FileCreateTransaction(client).setExpirationTime(

    Instant.now()

        .plus(Duration.ofSeconds(2592000))

)

     .addKey(operatorKey.getPublicKey())

     .setContents(fileContents);

var receipt = tx.executeForReceipt();

var newFileId = Objects.requireNonNull(receipt.getFileId());

// Get file contents

var contents = new FileContentsQuery(client)

  .setFileId(newFile.getFileId())

  .execute();

System.out.println("File content query results: " + contents.getFileContents().getContents().toStringUtf8())

//Delete file owned by operator key

TransactionReceipt txDeleteReceipt = new FileDeleteTransaction(client)

            .setFileId(newFileId)

            .executeForReceipt();

        if (txDeleteReceipt.getStatus() != ResponseCodeEnum.SUCCESS) {

            System.out.println("Error while deleting a file");

            return;

        }

System.out.println("File deleted successfully.");

“Hedera's asynchronous Byzantine fault tolerance gives me the peace of mind to focus on building an amazing product."

Oliver Bolton
CEO, CO-FOUNDER

Trust, but verify

With secure access and transparent file details, you can add a new level of trust to signed files. This is well suited to manage access and credentials, like a drivers license.

1: Add file

Add a file containing a hash of a credential to the public. For example, a city office uploads a citizen's driver license.

2: Owner keys

The file has the keys of both the driver and the city official attached to it. Both must sign to create the file, but either can sign to delete the file; in this case if the license expires or has too many points.

3: Revocation check

Owners can optionally provide file details and prove the file existed at a point in time. This can be checked by insurance providers, employers, and more.

A network for decentralized applications

Explore other Hedera network services to run powerful smart contracts and enable fast payments.

Cryptocurrency

Enable fast, low fee payments

Cryptocurrency payments allow you to transact without intermediaries to lower costs and make complex payments simple with code.
Smart Contract

Tokenize and exchange assets

The tokenized economy will change how we define ownership. Use the Solidity language to create assets, perform atomic swaps, or interact with outside oracles.
Consensus Service

Build directly on hashgraph

Write transactions at native speed for a scalable, cost-effective solution to manage exchange orders, audit logs, supply chain tracking, and endless possibilities.

Ready to start building?

Join a testnet or view the docs