web3-plugin-ipfs-registry
v1.0.1
Published
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.
Downloads
3
Readme
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
- Instantiate
web3
const provider = new HttpProvider(
"https://endpoints.omniatech.io/v1/eth/sepolia/public",
);
// const provider = new HttpProvider("HTTP://127.0.0.1:7545"); // Provider for Ganache environment
const web3 = new Web3(provider);
- Register plugin for use
web3.registerPlugin(new IPFSRegistryPlugin());
- Call the upload function
export const _upload = async (): Promise<UploadReturnData> => {
return await web3.ipfsRegistry.upload("src/usage.ts");
};
- Fetch uploaded CIDs
export const getCids = async (): Promise<void> => {
await web3.ipfsRegistry.listCids(
"0x8B90d90F2867D52878483B42bcA591F9Efe2931b",
);
};
- Run test (This runs the E2E test on both node and browser environment)
yarn run test:all
- 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.