Skip to content

Web3.js Plugin that have two main functions for uploading a provided local file to IPFS, then store the CID in a smart contract, and another function for listing all stored CIDs of given ethereum address.

Notifications You must be signed in to change notification settings

Gift-Stack/web3-plugin-ipfs-registry

Repository files navigation

web3-plugin-ipfs-registry

This is a plugin for uploading files into ipfs, and registering them in a smart contract, built with web3.js v4 plugin.

How to use

TL;DR: The usage.ts file has it implemented already!! 🚀

  1. Instantiate web3
const provider = new HttpProvider(
  "https://ethereum-sepolia.publicnode.com",
);
// const provider = new HttpProvider("HTTP://127.0.0.1:7545"); // Provider for Ganache environment
const web3 = new Web3(provider);

Here are a list of supported RPCs:

["https://ethereum-sepolia.publicnode.com", "https://endpoints.omniatech.io/v1/eth/sepolia/public", "https://rpc.sepolia.org", "https://sepolia.gateway.tenderly.co"]

There are more rpcs here

  1. Register plugin for use
web3.registerPlugin(new IPFSRegistryPlugin());
  1. Call the upload function
export const _upload = async (): Promise<UploadReturnData> => {
  return await web3.ipfsRegistry.upload("src/usage.ts");
};
  1. Fetch uploaded CIDs
export const getCids = async (): Promise<void> => {
  await web3.ipfsRegistry.listCids(
    "0x8B90d90F2867D52878483B42bcA591F9Efe2931b",
  );
};
  1. Run test (This runs the E2E test on both node and browser environment)
yarn run test:all
  1. Run build.
yarn run build

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

Web3.js Plugin that have two main functions for uploading a provided local file to IPFS, then store the CID in a smart contract, and another function for listing all stored CIDs of given ethereum address.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published