Hướng dẫn bắt đầu nhanh

Bắt đầu sử dụng Chaindoc trong vòng chưa đầy 10 phút. Hướng dẫn này bao gồm cả giao diện web và tích hợp API cho các cậu.

Dành cho người dùng cuối

Bước từng bước: Chữ ký đầu tiên của cậu

1Đăng kýTạo tài khoản miễn phí của cậu tại app.chaindoc.io. Xác minh địa chỉ email của cậu.

2Tải lên tài liệuNhấp vào 'Tạo tài liệu mới' và tải lên tệp của cậu. Hỗ trợ các định dạng PDF, tài liệu Office, hình ảnh (tối đa 50MB).

3Thêm chi tiết tài liệuNhập tên tài liệu, mô tả và thẻ để tổ chức. Chọn mức độ truy cập (riêng tư, nhóm hoặc công khai).

4Tạo yêu cầu chữ kýNhấp vào 'Yêu cầu chữ ký', thêm địa chỉ email của người nhận, đặt thời hạn và tùy chỉnh nội dung tin nhắn.

5Cấu hình luồng chữ kýChọn thứ tự ký tên (song song hoặc tuần tự), kích hoạt KYC nếu cần thiết, chọn tùy chọn thông báo.

6Gửi yêu cầuKiểm tra và gửi. Người nhận sẽ nhận được email kèm liên kết ký tên an toàn.

7Theo dõi tiến độTheo dõi trạng thái ký tên theo thời gian thực. Nhận thông báo khi chữ ký được thu thập.

8Tải xuống tài liệu đã kýSau khi hoàn tất, tải xuống tài liệu đã ký kèm theo chứng chỉ blockchain.

Dành cho các cậu phát triển

Tích hợp Chaindoc vào ứng dụng của cậu bằng cách sử dụng API REST và SDK của chúng tớ.

1. Lấy khóa API

2. Cài đặt SDK

Chọn SDK dựa trên trường hợp sử dụng của cậu:

# Node.js 18+ required
npm install @chaindoc_io/server-sdk

3. Tạo tài liệu đầu tiên của cậu qua API

server.ts
import { Chaindoc } from '@chaindoc_io/server-sdk';
import { readFile } from 'fs/promises';

// Initialize SDK
const chaindoc = new Chaindoc({
  secretKey: process.env.CHAINDOC_SECRET_KEY!,
});

// 1. Upload document
const buffer = await readFile('./contract.pdf');
const file = new Blob([buffer], { type: 'application/pdf' });
const { media } = await chaindoc.media.upload([file]);

// 2. Create document record
const doc = await chaindoc.documents.create({
  name: 'Service Agreement',
  description: 'Q4 2024 Contract',
  media: media[0],
  status: 'published', // Triggers blockchain verification
  hashtags: ['#contract', '#2024'],
  meta: [{ key: 'client', value: 'Acme Corp' }],
});

console.log('Document created:', doc.documentId);

4. Tạo yêu cầu chữ ký

server.ts
// Create signature request for multiple signers
const sigRequest = await chaindoc.signatures.createRequest({
  versionId: doc.document.versions[0].uuid,
  recipients: [
    { email: 'signer1@example.com' },
    { email: 'signer2@example.com' },
  ],
  deadline: new Date('2024-12-31'),
  message: 'Please review and sign this agreement',
  embeddedFlow: true, // Enable for frontend integration
});

console.log('Signature request created:', sigRequest.signatureRequest.uuid);

5. Tích hợp Giao diện Ký tên (Frontend)

Đối với việc ký tên nhúng trong ứng dụng web của cậu:

// Create embedded session for signer
const session = await chaindoc.embedded.createSession({
  email: 'signer1@example.com',
  metadata: {
    documentId: doc.documentId,
    signatureRequestId: sigRequest.signatureRequest.uuid,
  },
});

// Return sessionId to frontend
res.json({ sessionId: session.sessionId });

6. Theo dõi trạng thái và xử lý sự kiện

terminal
// Check signature request status
const status = await chaindoc.signatures.getRequestStatus(
  sigRequest.signatureRequest.uuid
);

if (status.signatureRequest.status === 'completed') {
  console.log('All signatures collected!');
  // Download signed document
  // Send notifications
  // Update your database
}

7. Cấu hình Webhooks (Tùy chọn)

Nhận thông báo thời gian thực cho các sự kiện:

webhooks.ts
// Configure webhook endpoint
app.post('/webhooks/chaindoc', (req, res) => {
  const event = req.headers['x-webhook-event'];
  const payload = req.body;
  
  switch (event) {
    case 'document.verified':
      console.log('Document verified on blockchain:', payload.txHash);
      break;
    case 'signature.request.completed':
      console.log('All signatures collected!');
      // Send notifications, update status, etc.
      break;
  }
  
  res.status(200).send('OK');
});

Ví dụ về quy trình làm việc hoàn chỉnh

Dưới đây là một ví dụ hoàn chỉnh từ đầu đến cuối kết hợp tất cả các bước:

complete-workflow.ts
import { Chaindoc } from '@chaindoc_io/server-sdk';
import { readFile } from 'fs/promises';

async function createSigningWorkflow() {
  const chaindoc = new Chaindoc({
    secretKey: process.env.CHAINDOC_SECRET_KEY!,
  });
  
  // Step 1: Upload document
  const buffer = await readFile('./contract.pdf');
  const file = new Blob([buffer], { type: 'application/pdf' });
  const { media } = await chaindoc.media.upload([file]);
  
  // Step 2: Create document
  const doc = await chaindoc.documents.create({
    name: 'Service Agreement',
    description: 'Contract for consulting services',
    media: media[0],
    status: 'published',
    hashtags: ['#contract'],
    meta: [],
  });
  
  // Step 3: Create signature request
  const sigRequest = await chaindoc.signatures.createRequest({
    versionId: doc.document.versions[0].uuid,
    recipients: [{ email: 'signer@example.com' }],
    deadline: new Date('2024-12-31'),
    embeddedFlow: true,
  });
  
  // Step 4: Create session for frontend
  const session = await chaindoc.embedded.createSession({
    email: 'signer@example.com',
    metadata: {
      documentId: doc.documentId,
      signatureRequestId: sigRequest.signatureRequest.uuid,
    },
  });
  
  return {
    documentId: doc.documentId,
    sessionId: session.sessionId,
  };
}

// Usage
const { documentId, sessionId } = await createSigningWorkflow();
console.log('Ready for signing:', { documentId, sessionId });

Các bước tiếp theo

  • Đọc Hướng dẫn cài đặt để biết chi tiết về việc thiết lập SDK.
  • Tham khảo Tài liệu API để xem danh sách đầy đủ các điểm cuối.
  • Kiểm tra tài liệu SDK để xem các ví dụ cụ thể cho từng khung làm việc (React, Vue, Angular)
  • Cài đặt Webhooks để nhận thông báo sự kiện theo thời gian thực
  • Kiểm tra các nguyên tắc bảo mật tốt nhất cho triển khai sản xuất

Câu hỏi thường gặp

Quá trình xác minh blockchain mất bao lâu?

Quá trình xác minh blockchain thường hoàn tất trong vòng 1-5 phút tùy thuộc vào mạng lưới. Tài liệu có sẵn ngay lập tức, quá trình xác minh diễn ra theo cách không đồng bộ.

Tớ có thể thử nghiệm mà không cần gói trả phí không?

Đúng vậy! Gói miễn phí bao gồm quyền truy cập giao diện web. Quyền truy cập API yêu cầu gói Business, nhưng cậu có thể sử dụng môi trường sandbox để thử nghiệm.

Chữ ký có giá trị pháp lý không?

Có, chữ ký Chaindoc tuân thủ các quy định của eIDAS, ESIGN Act và UETA. Xác minh blockchain cung cấp bằng chứng pháp lý bổ sung.

Các định dạng tệp nào được hỗ trợ?

PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, TXT, JPG, PNG, GIF, WEBP, SVG, MP4, AVI, MOV, WMV. Kích thước tệp tối đa: 50MB.