| title | Quickstart Guide |
|---|---|
| description | Get started with DaoSign in minutes |
This guide will help you quickly get started with DaoSign's core functionality. We'll walk through creating a schema, generating an attestation, collecting signatures, and verifying the agreement.
- An Ethereum wallet (like MetaMask)
- Some ETH for gas fees on your chosen network
- Basic understanding of blockchain transactions
# Install via npm
npm install daosign-client
# Or using yarn
yarn add daosign-clientimport { DaoSignClient } from 'daosign-client';
// Connect to a network (mainnet, testnet, or local)
const daosign = new DaoSignClient({
provider: window.ethereum, // Or your preferred provider
network: 'goerli', // Or the network of your choice
});
// Connect wallet
await daosign.connect();// Define a simple NDA schema
const ndaSchema = {
metadata: {
name: "Non-Disclosure Agreement",
description: "Standard NDA template",
attestation_type: "agreement",
is_public: true,
is_revokable: true,
expire_in: 31536000, // 1 year in seconds
is_nft: true,
nft_name: "NDA Proof",
nft_symbol: "NDAP"
},
schema_definition: [
{
definition_type: "string",
definition_name: "Company Name"
},
{
definition_type: "string",
definition_name: "Consultant Name"
},
{
definition_type: "uint256",
definition_name: "Agreement Date"
},
{
definition_type: "string",
definition_name: "Confidential Information Description"
}
],
signatory_policy: [] // Empty means no special requirements for signers
};
// Sign the schema creation request
const signature = await daosign.signSchema(ndaSchema);
// Create the schema on blockchain
const schemaId = await daosign.createSchema({
...ndaSchema,
signature
});
console.log(`Created schema with ID: ${schemaId}`);// Create a document instance from the schema
const ndaData = {
schema_id: schemaId,
attestation_result: [
{
attestation_result_type: "string",
name: "Company Name",
value: "Acme Corporation"
},
{
attestation_result_type: "string",
name: "Consultant Name",
value: "John Doe"
},
{
attestation_result_type: "uint256",
name: "Agreement Date",
value: Math.floor(Date.now() / 1000) // Current timestamp
},
{
attestation_result_type: "string",
name: "Confidential Information Description",
value: "All product designs, customer lists, and financial data"
}
],
recipient: "0xRecipientAddress...", // Address of recipient
signatories: [
"0xCompanyAddress...",
"0xConsultantAddress..."
] // Addresses required to sign
};
// Sign the attestation creation request
const attestationSignature = await daosign.signAttestation(ndaData);
// Create the attestation on blockchain
const attestationId = await daosign.createAttestation({
...ndaData,
signature: attestationSignature
});
console.log(`Created attestation with ID: ${attestationId}`);// Connect with company wallet
await daosign.connect({address: "0xCompanyAddress..."});
// Generate signature
const signature = await daosign.createSignatureForAttestation(attestationId);
// Submit signature to blockchain
await daosign.signAttestation(attestationId, signature);
console.log(`Attestation ${attestationId} signed by company`);// Connect with consultant wallet
await daosign.connect({address: "0xConsultantAddress..."});
// Generate signature
const signature = await daosign.createSignatureForAttestation(attestationId);
// Submit signature to blockchain
await daosign.signAttestation(attestationId, signature);
console.log(`Attestation ${attestationId} signed by consultant`);
// After all signatories sign, the Proof of Agreement is automatically generated// Get attestation details
const attestation = await daosign.getAttestation(attestationId);
console.log('Attestation data:', attestation);
// Get all signatures
const signatures = await daosign.getProofsOfSignature(attestationId);
console.log(`Found ${signatures.length} signatures:`, signatures);
// Get proof of agreement
const agreements = await daosign.getProofsOfAgreement(attestationId);
if (agreements.length > 0) {
console.log('Agreement is complete');
} else {
console.log('Agreement is not yet complete');
}
// Check NFT status if schema was configured for NFTs
const schema = await daosign.getSchema(attestation.schema_id);
if (schema.metadata.is_nft) {
const nftCollection = await daosign.getNftCollection(attestation.schema_id);
const owner = await nftCollection.ownerOf(attestationId);
console.log(`NFT for attestation ${attestationId} is owned by ${owner}`);
}// Only the creator can revoke
await daosign.connect({address: attestation.creator});
// Generate revocation signature
const revokeSignature = await daosign.createRevocationSignature(attestationId);
// Revoke the attestation
await daosign.revokeAttestation(attestationId, revokeSignature);
console.log(`Attestation ${attestationId} has been revoked`);This example shows how to create a schema that requires signatories to have previously received certain attestations:
// Define a schema that requires signatories to have verified identities
const loanAgreementSchema = {
metadata: {
name: "Loan Agreement",
description: "Peer-to-peer loan contract",
attestation_type: "agreement",
is_public: true,
is_revokable: false,
expire_in: 0, // Never expires
is_nft: true,
nft_name: "Loan Contract",
nft_symbol: "LOAN"
},
schema_definition: [
{ definition_type: "string", definition_name: "Lender Name" },
{ definition_type: "string", definition_name: "Borrower Name" },
{ definition_type: "uint256", definition_name: "Loan Amount" },
{ definition_type: "uint256", definition_name: "Interest Rate" },
{ definition_type: "uint256", definition_name: "Term in Months" },
{ definition_type: "string", definition_name: "Payment Terms" }
],
signatory_policy: [
{
operator: "0x01", // AND operator
signatory_description: "Verified Identity Requirement",
required_schema_id: [1] // Assuming schema ID 1 is for "Identity Verification"
}
]
};
// Sign and create the schema
const signature = await daosign.signSchema(loanAgreementSchema);
const loanSchemaId = await daosign.createSchema({
...loanAgreementSchema,
signature
});
console.log(`Created loan agreement schema with ID: ${loanSchemaId}`);DaoSign supports various data types in schemas and attestations. Here's how to use them:
// Schema with different data types
const multiTypeSchema = {
metadata: {
name: "Multi-Type Document",
description: "Example of different data types",
attestation_type: "example",
is_public: true,
is_revokable: true,
expire_in: 0
},
schema_definition: [
{ definition_type: "string", definition_name: "Text Field" },
{ definition_type: "boolean", definition_name: "Yes/No Field" },
{ definition_type: "uint256", definition_name: "Number Field" },
{ definition_type: "bytes", definition_name: "Binary Data Field" },
{ definition_type: "bytes32", definition_name: "Fixed Binary Field" },
{ definition_type: "address", definition_name: "Ethereum Address Field" }
],
signatory_policy: []
};
// Creating an attestation with these data types
const attestation = {
schema_id: schemaId,
attestation_result: [
{
attestation_result_type: "string",
name: "Text Field",
value: "This is a text value"
},
{
attestation_result_type: "boolean",
name: "Yes/No Field",
value: true
},
{
attestation_result_type: "uint256",
name: "Number Field",
value: 12345
},
{
attestation_result_type: "bytes",
name: "Binary Data Field",
value: "0x1a2b3c4d"
},
{
attestation_result_type: "bytes32",
name: "Fixed Binary Field",
value: "0x1a2b3c4d1a2b3c4d1a2b3c4d1a2b3c4d1a2b3c4d1a2b3c4d1a2b3c4d1a2b3c4d"
},
{
attestation_result_type: "address",
name: "Ethereum Address Field",
value: "0x1234567890123456789012345678901234567890"
}
],
recipient: "0xRecipientAddress...",
signatories: ["0xSignatoryAddress..."]
};- Explore Core Concepts to understand DaoSign's architecture
- Check out Tutorials for more detailed examples
- See Technical Reference for development details
- Learn about Signatory Policies for advanced use cases
- Understand NFT Integration for tokenized attestations
Now you're ready to start using DaoSign for your document signing needs!