Skip to content

OpacityLabs/solidity-sdk

Repository files navigation

OpacitySDK for Solidity

Quick Start

1. Clone and Setup

git clone <repository-url>
cd opacity-solidity-sdk
forge install

2. Environment Setup

# Copy the example environment file
cp .env.example .env

# Edit .env and add your private key
PRIVATE_KEY=your_private_key_here

3. Deploy on Holesky Testnet

# Deploy SimpleVerificationConsumer
forge script script/Deploy.s.sol:Deploy --sig "run(address,address)" <BLS_ADDRESS> <REGISTRY_COORDINATOR> --rpc-url holesky --broadcast

Deployment:

  • Deploys SimpleVerificationConsumer with provided BLS signature checker
  • Writes addresses to deployments/latest.json
  • Verifies contracts are properly linked
  • Outputs deployment summary

Deployment JSON Output

After deployment, addresses are saved to deployments/latest.json:

{
  "blsSignatureChecker": "0x2a55810daCeF9197d51B94A21c67d88b8d99b379",
  "registryCoordinator": "0x3e43AA225b5cB026C5E8a53f62572b10D526a50B",
  "simpleVerificationConsumer": "0x1b4468ce3306f886d4a741950acE0238e4204cdb",
  "timestamp": 1234567890
}

Usage Examples

Basic Verification (SimpleVerificationConsumer)

// Create verification parameters
OpacitySDK.VerificationParams memory params = OpacitySDK.VerificationParams({
    quorumNumbers: quorumNumbers,
    referenceBlockNumber: referenceBlockNumber,
    nonSignerStakesAndSignature: nonSignerStakesAndSignature,
    userAddress: userAddress,
    platform: "twitter",
    resource: "followers",
    value: "10000",
    threshold: 1000,
    signature: "signature_data",
    operatorCount: 5
});

// Verify the data
bool success = simpleConsumer.verifyUserData(params);

Advanced Verification with Storage (StorageQueryConsumer)

// Verify and store the result
(bool success, string memory verifiedValue) = storageQueryConsumer.verifyPrivateData(params);

if (success) {
    // Get stored verification details
    (bool isValid, string memory value, uint256 timestamp, bytes32 hash) = 
        storageQueryConsumer.getUserVerification(userAddress);
}

Development

Build

forge build

Test

forge test
  • no tests currently

Format Code

forge fmt

Gas Snapshots

forge snapshot

Contract Architecture

OpacitySDK (Base Contract)

  • VerificationParams struct: Wraps all verification parameters
  • verify(): Main verification function returning boolean
  • Configurable thresholds: Quorum and block staleness settings

Example Contracts

  • SimpleVerificationConsumer: Demonstrates basic verification with events
  • StorageQueryConsumer: Shows advanced usage with storage and retrieval functions

Dependencies

  • EigenLayer Middleware: BLS signature checking and registry coordination
  • Foundry: Development and testing framework
  • OpenZeppelin: Standard library contracts (via EigenLayer)

Deployment Configuration

Required Arguments

forge script script/Deploy.s.sol:Deploy --sig "run(address,address)" <BLS_ADDRESS> <REGISTRY_COORDINATOR> --rpc-url holesky --broadcast
  • blsSignatureCheckerAddress: Address of the BLS signature checker contract
  • registryCoordinator: Address of the registry coordinator contract

Foundry Documentation

For more information about Foundry, visit: https://book.getfoundry.sh/

Additional Foundry Commands

# Local development node
anvil

# Cast commands for chain interaction
cast <subcommand>

# Help
forge --help
anvil --help
cast --help

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5