This repository contains Rust-based smart contracts for a decentralized authentication system. The contracts facilitate account creation, authentication, and account management using smart contract-based logic.
The system consists of three main contracts:
- Responsible for deploying new account contracts in a deterministic manner.
- Uses a provided WebAssembly (WASM) hash to deploy contract instances.
- Ensures only authorized entities can initiate deployments.
- Emits events upon successful contract deployments.
- Handles multi-signature authentication and permission management.
- Manages a dynamic set of signers, enforcing authentication thresholds.
- Supports account and factory management through stored contexts.
- Implements flexible authorization rules for external contract calls.
- Allows addition and removal of signers, accounts, and factories.
- Ensures authentication by verifying Ed25519 cryptographic signatures.
- Emits events for key contract updates such as signer additions and removals.
- Represents an individual user account.
- Ensures authentication by verifying Secp256r1 cryptographic signatures, in line with WebAuthn specifications..
- Provides methods for account recovery, device management, and security updates.
- Uses a multi-device authentication model with public keys tied to registered devices.
- Supports recovery mechanisms through a designated recovery address.
- Implements a custom authentication interface to validate digital signatures and verify ownership.
- Emits events for device additions, removals, and security updates.
- The Account Factory deploys a new Account Contract when a user registers.
- The Auth Controller manages authentication flows, including key validation and session authorization.
- The Account Contract holds user credentials, allowing secure and decentralized identity management.
- Rust toolchain
- Cargo package manager
- Blockchain runtime (depends on deployment environment)
- Install Stellar CLI:
cargo install stellar-cli- Setup your Stellar account:
stellar account create --network testnet- Fund your testnet account:
- Visit: https://laboratory.stellar.org/
- Use the friendbot to fund your testnet account
To deploy the KindFi NFT contract, simply run:
# For testnet (default)
./deploy.sh
# For mainnet
./deploy.sh public your_account_nameMake sure you have:
- Stellar CLI installed
- A funded account on the target network
- The necessary permissions set up
The script will handle the build and deployment process automatically and save the deployment information to deployment-info.txt.
- Check contract status:
stellar contract inspect \
--network testnet \
--id <contract_id>- View contract storage:
stellar contract storage \
--network testnet \
--id <contract_id>- Testnet: Use
--network testnet - Mainnet: Use
--network public
Create a .env file:
cp .env.sample .env- "Invalid account": Make sure your account is funded
- "Invalid sequence number": Wait a moment and retry
- "Contract already exists": Use a new WASM hash
- Make changes to contract
- Build contract (
cargo build) - Install new WASM
- Deploy new instance
- Initialize new instance
- Test new deployment
- Always test on testnet first
- Keep secret keys secure
- Verify contract ID after deployment
- Check all transactions before signing