Introduction
In the world of web3, data is the lifeblood of innovation. From NFTs to decentralized applications (dApps), the ability to store, access, and interact with data efficiently is critical.
However, traditional blockchains like Ethereum and Solana are optimized for execution, not storage, making data storage expensive and limited. Even early datachains, designed for affordable storage, fall short by treating data as static and isolated.
IRYS is the world’s first programmable datachain. It redefines data storage by making it permanent, affordable, and interactive. And now, thanks to the efforts of the team at Horus Labs, Irys is integrated with Starknet, bringing its powerful capabilities to the Starknet ecosystem.
This article will explore what Irys is, how it works, and how Starknet developers can leverage it to build scalable, data-rich applications. Let’s dive in!
What is Irys?
Irys is a programmable datachain designed to solve the limitations of traditional blockchains and early datachains. Unlike execution-focused blockchains that struggle with expensive and limited storage, or early datachains that only store data passively, Irys combines affordable, permanent storage with programmability to create a new primitive for decentralized applications.
Key Features of Irys:
- Permanent Storage: Data uploaded to Irys is stored permanently, ensuring it remains accessible and tamper-proof.
- Programmable Data: Data on Irys can carry embedded properties (e.g., ownership, royalties) and interact with smart contracts, making it dynamic and versatile.
- Verifiability: Cryptographic proofs ensure data is accurate, available, and reliable.
- Predictable Pricing: Irys uses a self-correcting pricing mechanism to stabilize storage costs, making it easier for developers to budget.
- By integrating Irys with Starknet, developers can now leverage these features to build scalable, data-driven applications.
Why is Irys on Starknet?
Starknet’s ZK-Rollup Layer 2 solution is designed to scale Ethereum by offloading computation and storage. However, even Starknet faces challenges when it comes to storing large amounts of data affordably. This is where Irys comes in.
Benefits for Starknet Developers:
- Affordable Storage: Offload data storage to Irys, reducing costs and improving scalability.
- Programmable Data: Enable dynamic interactions between data and Starknet smart contracts.
- Enhanced Use Cases: Build applications like permanent NFT metadata storage, decentralized content publishing, and verifiable data marketplaces.
- Decentralization: Leverage Irys’s decentralized infrastructure to enhance trust and security.
Recognizing the need for a robust data storage solution on Starknet, Horus Labs—a blockchain research and development lab focused on building user-friendly web3 products—took the initiative to collaborate with the Irys team. Their efforts have made Irys accessible to the Starknet community, unlocking new possibilities for developers and users alike.
How Irys Works
Irys’s architecture is designed to make data storage efficient, reliable, and interactive. Here’s how it works:
Multi-Ledger Architecture:
- Submit Ledger: A temporary storage layer where data is uploaded and validated.
- Publish Ledger: A permanent storage layer where verified data is stored with cryptographic proofs.
Programmable Data:
Data on Irys can carry embedded properties, such as ownership rights, access controls, or royalty structures. These properties enable data to interact with smart contracts, making it more than just static information.
Verifiability:
Irys ensures data integrity through:
- Proof of Upload: Cryptographic proofs that data has been accurately uploaded.
- Data Availability Challenges: Miners must periodically prove they are maintaining unique copies of data.
- Matrix Packaging: A mechanism to verify that miners store unique data copies, preventing duplication or neglect.
IrysVM:
IrysVM is a virtual machine that enables seamless integration of storage and execution. It allows smart contracts to interact directly with data stored on Irys, unlocking new possibilities for decentralized applications.
Getting Started with Irys on Starknet
You can start uploading data to Irys using the Irys SDK.
Prerequisites:
- Node.js (v18+)
- Yarn or npm
- A Starknet wallet(Argent or Braavos) with testnet funds (for Sepolia testnet).
- Basic understanding of TypeScript.
Step 1: Set Up the Project
- Initialize a Node.js Project:
mkdir irys-starknet-demo && cd irys-starknet-demo
yarn init -y
- Install Dependencies:
{
"name": "irys",
"version": "1.0.0",
"type": "module",
"main": "index.ts",
"license": "MIT",
"scripts": {
"start": "npx tsx src/index.ts"
},
"dependencies": {
"@irys/query": "^0.0.8",
"@irys/sdk": "^0.2.9",
"@irys/upload-core": "^0.0.10",
"@irys/upload-starknet-node": "^0.0.1",
"bignumber.js": "^9.1.2",
"dotenv": "^16.4.7",
"starknet": "^6.21.1",
"starknet-merkle-tree": "^1.0.1"
},
"devDependencies": {
"@types/node": "^20.11.5",
"tsx": "^4.7.0",
"typescript": "^5.3.3"
}
}
Copy the above into your package.json file in your project root and run:
yarn install
Step 2: Configure Environment Variables
Create a .env file in your project root:
PRIVATE_KEY=your_starknet_private_key_here
Note: Never expose your private key publicly. Use a testnet wallet for this demo.
Step 3: Upload Data to Irys
Create a file src/index.ts
and add the following code:
import { Uploader } from "@irys/upload";
import { Starknet } from "@irys/upload-starknet-node";
import 'dotenv/config'
const userAddress = "0x049709844D79e49757c4fd5A7092D00DE680703E9c77eD3BB43Bf94eB7f2e9b4";
const privateKey = process.env.PRIVATE_KEY;
const rpcUrl = "https://starknet-sepolia.public.blastapi.io";
const getIrysUploader = async() => {
const irysUploader = await Uploader(Starknet(userAddress)).withWallet(privateKey).devnet().withRpc(rpcUrl);
return irysUploader;
}
const uploadData = async() => {
const irysUploader = await getIrysUploader();
const dataToUpload = "Hello world";
try {
// upload text
const receipt = await irysUploader.upload(dataToUpload);
console.log(`Data uploaded ===> https://gateway.irys.xyz/${receipt.id}`);
// upload image
const image = "./images/pfp.jpg";
const tags = [{ name: "coloniz", value: "PFP" }];
const receipt2 = await irysUploader.uploadFile(image, { tags: tags });
console.log(`Data uploaded ===> https://gateway.irys.xyz/${receipt2.id}`);
}
catch(error) {
console.log(error);
}
}
const queryData = async() => {
const irysUploader = await getIrysUploader();
const output = irysUploader
.query({url:"https://devnet.irys.xyz/graphql"})
.search("irys:transactions")
.ids(["3Lt6qPMteJmmh7z184kziSwCjUDpB83tQjRuaezZu97j", "6HfJjfwHTEmnraxoeCWuRC1jC1DGc1x9i2ZdjVPMdJFw"]);
console.log("output:", output)
}
uploadData();
// queryData();
Step 4: Run the Code
- Create an images folder in your project and add a test image (e.g.,
pfp.jpg
). - Execute the script:
yarn start
- Example Output:
Step 5: Integrate with Starknet Smart Contracts:
Use the transaction ID to reference Irys data in your Cairo smart contract.
Here’s the full sample code example of uploading data to Irys from Starknet.
Conclusion
Irys’s integration with Starknet marks a new era for decentralized data storage and programmability. By combining Irys’s powerful features with Starknet’s scalability, developers can build innovative, data-driven applications like never before.
Thank you to the Starknet community, the Irys team, and Horus Labs for making this integration possible. Let’s build the future of web3 together!
Start using Irys on Starknet today! Share your feedback and ideas with the Horus Labs and Irys teams. For more resources, check out: