Skip to content

bhavesh-ram/media-node-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MediaNode Solidity Smart Contract

Prerequisites

1. Clone the Repository

git clone https://github.com/bhavesh-ram/media-node-module.git
cd media-node-module

2. Install Dependencies

Run the following command

npm install

3. Initialize Hardhat (if not already done)

npx hardhat

Choose "Create a basic sample project" and follow the prompts.

4. Compile the Contract

npx hardhat compile

5. Run a Local Ethereum Node

In a separate terminal, start Hardhat's local node:

npx hardhat node

6. Deploy the Contract

Create a deploy script in the scripts/ directory, e.g., deploy.js (already present)

const hre = require("hardhat");
async function main() {
  const [deployer] = await hre.ethers.getSigners();
  console.log("Deploying contracts with the account:", deployer.address);

  const MediaNode = await hre.ethers.getContractFactory("MediaNode");
  const mediaNode = await MediaNode.deploy();
  await mediaNode.waitForDeployment();
  console.log("MediaNode deployed to:", mediaNode.address);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Run the deploy script:

npx hardhat run scripts/deploy.js --network localhost

8. Interact with the Contract

You can use the Hardhat console:

npx hardhat console --network localhost

Example interaction:

const hre = require("hardhat");
const [owner] = await hre.ethers.getSigners();
const MediaNode = await hre.ethers.getContractFactory("MediaNode");
const mediaNode = await MediaNode.attach("<deployed_contract_address>");

// Register a node
await mediaNode.registerMediaNode({
  id: "node1",
  price_per_hour: 100,
  name: "Node Name",
  description: "Node Description",
  url: "http://example.com",
  cpu: 4,
  ram_in_gb: 16,
  storage_in_gb: 256
}, { value: 10 });

About

A Solidity Contract for Media node module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors