Integration of SmartCheck with Odoo
Certify Odoo data from the server with SmartCheck
SmartCheck is a feature of Code Contract that allows you to generate unique, secure, and immutable digital evidence in just seconds—at an affordable cost.
One of its most common applications is the certification of documents and data within Odoo. Below, we explain how you can perform these registrations easily.
Step 1: Obtain the authentication token
To use the SmartCheck API, you must first authenticate via a POST request to obtain a JWT token.
Authentication request (HTTP Request)
POST /login HTTP/1.1
Host: api.codecontract.io
Content-Type: application/json
{
"email": "[email protected]",
"password": "your_password"
}
Expected response
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Important:
✔️ The returned token must be stored and included in every subsequent request as a Bearer Token in the authorization header.
✔️ If Odoo uses OAuth for authentication, you must first obtain an OAuth token and then send it to SmartCheck.
Step 2: Certify documents and/or data from Odoo using SmartCheck
Once authenticated, you can send documents and/or data from Odoo to be certified on the blockchain.
1️⃣ Get the document content from Odoo
Example in Python (Odoo API):
import xmlrpc.client
URL = "https://your-odoo-server.com"
DB = "your_database_name"
USERNAME = "[email protected]"
PASSWORD = "your_password"
common = xmlrpc.client.ServerProxy(f'{URL}/xmlrpc/2/common')
uid = common.authenticate(DB, USERNAME, PASSWORD, {})
models = xmlrpc.client.ServerProxy(f'{URL}/xmlrpc/2/object')
def get_document_content(document_id):
"""Retrieve the content of a document from Odoo"""
document = models.execute_kw(DB, uid, PASSWORD, 'ir.attachment', 'read', [document_id], {'fields': ['datas']})
return document[0]['datas'] if document else None
2️⃣ Send the document to SmartCheck for certification
import requests
import base64
def certify_document(document_content):
"""Send document content to SmartCheck for certification"""
url = "https://api.codecontract.io/smartcheck/createTreeAndRegisterMerkleRoot"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = {
"data": [document_content]
}
response = requests.post(url, json=payload, headers=headers)
return response.json()
# Retrieve document from Odoo and certify
document_content = get_document_content(123) # Document ID in Odoo
certification_response = certify_document(document_content)
print("Certification result:", certification_response)
Expected response:
{
"merkleRoot": "abc123...",
"transactionId": "tx123...",
"status": "success"
}
✔️ merkleRoot: Merkle root generated from the document and/or data content.
✔️ transactionId: ID of the blockchain transaction.
✔️ status: Indicates whether the certification was successful.
Step 3: Verify a certified document
If you need to verify that a document has been certified, you can check the proof in SmartCheck.
Request to retrieve certification details
GET /smartcheck/reportsProofDetail?reportId=your_report_id HTTP/1.1
Host: api.codecontract.io
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
Expected response:
{
"reportId": "your_report_id",
"merkleRoot": "abc123...",
"data": [
"certified document"
],
"status": "verified"
}
Summary
✔️ Step 1: Obtain the JWT token via authentication with Odoo.
✔️ Step 2: Use the Odoo API to retrieve document and/or data content.
✔️ Step 3: Send the content to SmartCheck to certify it on the blockchain.
✔️ Step 4: Verify the certification when needed.
If you need more information or support, contact the Code Contract team. 🚀
