Nhảy tới nội dung

Registry (Basic)

Registry is a basic Smart Contract for registering accounts and devices, storing metadata URLs and device information. It is suitable for use cases that require a simpler structure than EDHAccountRegistry.

Data Structures

struct AccountRecord {
string metadataUrl; // Account metadata URL
uint timestamp; // Registration timestamp
}

struct DeviceRecord {
uint256 deviceId; // Device ID
bytes32 deviceName; // Device name (keccak256 hash)
string metadataUrl; // Device metadata URL
uint timestamp; // Registration timestamp
}

Events

event AccountRegistered(address id, uint timestamp);
event DeviceRegistered(address id, uint256 deviceId, uint timestamp);

Functions

Interface: Registry

contract Registry {

// Register an account with a metadata URL (owner only)
function registerAccount(string memory metadataUrl) public onlyOwner;

// Register a new device (owner only)
function registerDevice(
uint256 deviceId,
string memory deviceName,
string memory metadataUrl
) public onlyOwner;

// Read account metadata URL
function getAccount() public view returns (string memory);

// List all devices
function getDevices() public view returns (DeviceRecord[] memory);

// Get device information by deviceId
function getDeviceInfo(uint256 deviceId) public view returns (DeviceRecord memory);
}

registerAccount : Registers an account with a metadata URL. Each address can only register once. Can only be called by the contract owner.

registerDevice : Adds a new device to the account. The device name is hashed with keccak256 to prevent duplicate names. Each device has a deviceId, deviceName, and metadataUrl.

getAccount : View function for reading the current account's metadata URL.

getDevices : View function for listing all devices of the account.

getDeviceInfo : View function for looking up device information by deviceId.

Comparison with EDHAccountRegistry

FeatureRegistry (Basic)EDHAccountRegistry
PKI (Public Key Infrastructure)NoneYes — stores encryption public keys
Multi-Device WalletNoneYes — EDHAccount is a multi-owner wallet
Data StorageMetadata URLOn-chain public keys + SeedVault
Access ControlOwner onlyAll active devices
Meta-Transaction (ERC-2771)Not supportedSupported
End-to-End EncryptionNoneYes — via NaCl key exchange
Suitable ForSystems requiring a simple structureFull EDH system
mẹo

For full EDH platform usage, it is recommended to use EDHAccountRegistry, which supports end-to-end encryption, multi-device management, and meta-transactions.

See Also

  • Account — Full EDHAccountRegistry and EDHAccount