Data Integrity

import NeucronSDK from "./src/neucron-sdk.js";

const neucron = new NeucronSDK();

await neucron.authentication.login({ email: "your-email@example.com", password: "your-password" });

Upload File

You can easily upload a file to Neucron using the uploadFile function, supporting options such as specifying the file path, data, and wallet ID. In a browser environment, you need to create an input element to handle file selection.

// For browser:
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.onchange = async () => {
  console.log(await neucron.dataIntegrity.uploadFile({ filePath: fileInput.files[0] }));
};

// For Node.js:
console.log(await neucron.dataIntegrity.uploadFile({ filePath: 'path/to/your/file.png' }));

Upload Encrypted File

For enhanced security, use the uploadEncryptFile function to upload an encrypted file. Provide the file path, public key, and an optional wallet ID.

// For browser:
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.onchange = async () => {
  console.log(await neucron.dataIntegrity.uploadEncryptFile({ filePath: fileInput.files[0], publicKey: "your-public-key" }));
};

// For Node.js:
console.log(await neucron.dataIntegrity.uploadEncryptFile({ filePath: 'path/to/your/file.png', publicKey: "your-public-key" }));

Post Data

Utilize the postData function to post data to Neucron, including a message and an optional wallet ID.

console.log(await neucron.dataIntegrity.postData({ message: "Your Message" }));
console.log(await neucron.dataIntegrity.postData({ message: "Your Message", walletId: "your-wallet-id" }));

Upload File on Ordinal

Upload a file to a specific ordinal using the uploadFileOnOrdinal function. Specify the file path and an optional wallet ID.

// For browser:
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.onchange = async () => {
  console.log(await neucron.dataIntegrity.uploadFileOnOrdinal({ filePath: fileInput.files[0] }));
};

// For Node.js:
console.log(await neucron.dataIntegrity.uploadFileOnOrdinal({ filePath: 'path/to/your/file.png' }));

Upload Hashed File

Upload a hashed file with the uploadHashedFile function. Provide the file path and an optional wallet ID.

// For browser:
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.onchange = async () => {
  console.log(await neucron.dataIntegrity.uploadHashedFile({ filePath: fileInput.files[0] }));
};

// For Node.js:
console.log(await neucron.dataIntegrity.uploadHashedFile({ filePath: 'path/to/your/file.png' }));

API Response

Upon successful API calls, you can expect a response in the following format:

{
  "data": {
    "txid": "1ba5f866f2aa22622c85b0337ad63834587f3001c0e7155dd25d5db8b04241e5"
  },
  "status_code": 200
}
  • data: Contains the specific data returned by the API call.

    • txid: Transaction ID associated with the operation.

  • status_code: Indicates the HTTP status code of the response. A status code of 200 signifies a successful request.

Ensure proper handling of the response in your application based on the information provided in the data field, and check the status_code to confirm the success of the operation.

Note: The Neucron SDK is compatible with both Node.js and browser-based environments. Choose the appropriate import statement based on your environment.


This version includes instructions on how to handle file inputs in both browser and Node.js environments. Feel free to adjust as needed.

Last updated