API Reference

Complete reference documentation for all Neo Service Layer contracts and their methods.

Core Services

UserManagementContract

Manages user registration, authentication, and profile management.

Methods

C# Interface
// Register a new user
public static bool RegisterUser(UInt160 userHash, string username, string email)

// Authenticate user
public static bool AuthenticateUser(UInt160 userHash, string password)

// Update user profile
public static bool UpdateProfile(UInt160 userHash, string newEmail, string newUsername)

// Get user information
public static UserInfo GetUser(UInt160 userHash)

// Check if user exists
public static bool UserExists(UInt160 userHash)

DataStorageContract

Provides secure, encrypted data storage with access control.

C# Interface
// Store data with encryption
public static bool StoreData(UInt160 owner, string key, ByteString data, bool encrypted)

// Retrieve stored data
public static ByteString GetData(UInt160 requester, string key)

// Delete stored data
public static bool DeleteData(UInt160 owner, string key)

// Grant access to data
public static bool GrantAccess(UInt160 owner, string key, UInt160 grantee)

// Revoke access to data
public static bool RevokeAccess(UInt160 owner, string key, UInt160 grantee)

AccessControlContract

Role-based access control with hierarchical permissions.

C# Interface
// Create a new role
public static bool CreateRole(string roleName, string[] permissions)

// Assign role to user
public static bool AssignRole(UInt160 user, string roleName)

// Check if user has permission
public static bool HasPermission(UInt160 user, string permission)

// Revoke role from user
public static bool RevokeRole(UInt160 user, string roleName)

// Get user roles
public static string[] GetUserRoles(UInt160 user)

Enterprise Services

IdentityManagementContract

Enterprise-grade identity verification and management.

C# Interface
// Create digital identity
public static bool CreateIdentity(UInt160 user, string identityData, string[] credentials)

// Verify identity
public static bool VerifyIdentity(UInt160 user, string credential)

// Add credential to identity
public static bool AddCredential(UInt160 user, string credentialType, string credentialData)

// Revoke credential
public static bool RevokeCredential(UInt160 user, string credentialId)

// Get identity status
public static IdentityStatus GetIdentityStatus(UInt160 user)

PaymentProcessingContract

Multi-currency payment processing with escrow support.

C# Interface
// Process payment
public static bool ProcessPayment(UInt160 from, UInt160 to, BigInteger amount, UInt160 tokenHash)

// Create escrow
public static string CreateEscrow(UInt160 buyer, UInt160 seller, BigInteger amount, string conditions)

// Release escrow
public static bool ReleaseEscrow(string escrowId, UInt160 releaser)

// Refund escrow
public static bool RefundEscrow(string escrowId, UInt160 refunder)

// Get payment history
public static PaymentRecord[] GetPaymentHistory(UInt160 user)

Specialized Services

AnalyticsContract

On-chain analytics and data aggregation services.

C# Interface
// Track event
public static bool TrackEvent(string eventName, string eventData, UInt160 user)

// Get analytics data
public static AnalyticsData GetAnalytics(string metric, uint timeframe)

// Create custom metric
public static bool CreateMetric(string metricName, string aggregationType)

// Generate report
public static ReportData GenerateReport(string reportType, uint startTime, uint endTime)

MarketplaceContract

Decentralized marketplace for digital assets and services.

C# Interface
// List item for sale
public static string ListItem(UInt160 seller, string itemData, BigInteger price, UInt160 tokenHash)

// Purchase item
public static bool PurchaseItem(string itemId, UInt160 buyer)

// Update listing
public static bool UpdateListing(string itemId, BigInteger newPrice, UInt160 seller)

// Cancel listing
public static bool CancelListing(string itemId, UInt160 seller)

// Get marketplace stats
public static MarketStats GetMarketplaceStats()

Industry-Specific Services

SupplyChainContract

End-to-end supply chain tracking and verification.

C# Interface
// Create product
public static string CreateProduct(string productData, UInt160 manufacturer)

// Add supply chain step
public static bool AddSupplyChainStep(string productId, string stepData, UInt160 participant)

// Verify product authenticity
public static bool VerifyProduct(string productId, string verificationData)

// Get product history
public static SupplyChainStep[] GetProductHistory(string productId)

// Transfer product ownership
public static bool TransferOwnership(string productId, UInt160 newOwner)

HealthcareContract

Secure healthcare data management with privacy compliance.

C# Interface
// Create patient record
public static bool CreatePatientRecord(UInt160 patient, string encryptedData, UInt160 provider)

// Grant access to medical data
public static bool GrantMedicalAccess(UInt160 patient, UInt160 provider, string[] dataTypes)

// Add medical record
public static bool AddMedicalRecord(UInt160 patient, string recordData, UInt160 provider)

// Revoke medical access
public static bool RevokeMedicalAccess(UInt160 patient, UInt160 provider)

// Get patient consent status
public static ConsentStatus GetConsentStatus(UInt160 patient, UInt160 provider)

Common Types & Structures

Data Structures

C# Types
// User Information
public struct UserInfo
{
    public string Username;
    public string Email;
    public uint CreatedAt;
    public bool IsActive;
}

// Service Response
public struct ServiceResponse
{
    public bool Success;
    public string Message;
    public ByteString Data;
}

// Access Permission
public struct Permission
{
    public string Name;
    public string Description;
    public uint Level;
}

Error Codes

Authentication Errors

  • AUTH_001 - Invalid credentials
  • AUTH_002 - User not found
  • AUTH_003 - Account locked
  • AUTH_004 - Session expired

Permission Errors

  • PERM_001 - Access denied
  • PERM_002 - Insufficient privileges
  • PERM_003 - Role not found
  • PERM_004 - Permission expired

Data Errors

  • DATA_001 - Data not found
  • DATA_002 - Invalid format
  • DATA_003 - Encryption failed
  • DATA_004 - Storage limit exceeded