Interaction with protocol

Support information

SID

SID is an entity holding your users data. Here is it's schema.

struct SID {
    bytes32 SIDId;         // SID id
    bytes32 schemaId;      // Id of the schema used for this SID
    uint64 expirationDate; // Timestamp in seconds when SID expires
    uint64 revocationDate; // Timestamp in seconds when SID was revoked
    bool revoked;          // Is this SID revoked
    address user;          // Address associated with this SID
    bytes data;            // SID's data 
    string metadata;       // Any additional data
}

While in metadata field could be anything you want, initially it was designed for storing link to some offchain data related to SID. Same as metadata in NFT.

Connectors

We use connectors for working with different crosschain protocols. For now we support only 2 protocols:

Protocol
Connector id

Hyperlane

1

LayerZero

2

If for some reason neither accidentally or purposefully message would be targeted to the same chain it sent from then any connector id would be ignored and message would be redirected to the destination contract.

Calculating fee

To calculate fee you should use following functions depending on the desired action:

contract SingleIdentifierID {
    // Call this if you want a fee for registering SID 
    function calculateRegisteringSidFee(
        bytes32 _emitterId,        // Your emitter id
        uint32 _connectorId,       // Connector id you want to use
        address _user,             // Address of the SIDs associated user
        uint64 _expirationDate,    // Timestamp in seconds when SID should expire
        bytes calldata _data,      // SID data
        string calldata _metadata  // SID metadata
    ) public view returns (uint256)
    
    // Call this if you want a fee for updating SID 
    function calculateUpdatingSidFee(
        bytes32 _emitterId,        // Your emitter id
        uint32 _connectorId,       // Connector id you want to use
        bytes32 _sidId,            // Id of the SID you want to update
        uint64 _expirationDate,    // New expiration date 
        bytes calldata _data,      // New data
        string calldata _metadata  // New metadata
    ) public view returns (uint256)
}

Registering SID

You will need following data:

  • Id of your emitters schema

  • Address of the SID's user

  • User data according to your schema

  • Metadata - String with any additional data. For example link to IPFS with some additional data

It's only possible to register a single SID for a combination of user address and schema.

Attempt to register a second one will successfully send a crosschain message but execution on the destination chain will fail.

Note that only chosen user will be able to register this SID.

Firstly you should get digest.

contract SingleIdentifierID {
    function getRegisteringSidDigest(
        bytes32 _schemaId,        // Id of schema that is yoused by your emitter
        address _user,            // Address associated with the SID
        bytes calldata _data,     // SID's data
        string calldata _metadata // SID's metadata
    ) public view returns (bytes32)
}

Then you should sign this hash with your emitter wallet.

// example for ethers.js
const signature = await signer.signMessage(message);

After signing a user's data you need to calculate a fee and call the following function with the data collected before. Fees should be passed as a value.

contract SingleIdentifierID {
    function registerSID(
        bytes32 _emitterId,        // Your emitter id
        uint32 _connectorId,       // Connector id
        bytes calldata _data,      // User data
        bytes calldata _signature, // Signature, generated in the previous step
        string calldata _metadata  // User Metadata
    ) external payable
}

Accessing SID

To request SID you should call singleIdentifierData function on SingleIdentifierRegistry.

Note that SIDs are stored only on the chain where their schema was registered. Don't miss the chain.

struct SID {
    bytes32 SIDId;         // SID id
    bytes32 schemaId;      // Id of the schema used for this SID
    uint64 expirationDate; // Timestamp in seconds when SID expires
    uint64 revocationDate; // Timestamp in seconds when SID was revoked
    bool revoked;          // Is this SID revoked
    address user;          // Address associated with this SID
    bytes data;            // SID's data 
    string metadata;       // Any additional data
}

contract SingleIdentifierRegistry {
    function singleIdentifierData(
        bytes32 _sidId // Id of the SID
    ) public returns(SID)
}

Updating SID

Updating is pretty much the same as registering but with another data and functions.

You will need following data:

  • Id of the SID you want to update

  • New expiration timestamp

  • New data

  • New metadata

Firstly you should get digest.

contract SingleIdentifierID { 
    function getUpdatingSidDigest(
        bytes32 _sidId,
        uint64 _expirationDate,
        bytes calldata _data,
        string calldata _metadata
    ) public view returns (bytes32)
}

Then you should sign this hash with your emitter wallet.

// example for ethers.js
const signature = await signer.signMessage(message);

After signing a user's data you need to call the following function with the data collected before. Fees should be passed as a value.

contract SingleIdentifierID {
    function updateSID(
        bytes32 _emitterId,        // Your emitter id
        uint32 _connectorId,       // Connector id
        bytes32 _sidId,            // Id of the SID you want to update
        uint64 _expirationDate,    // New expiration timestamp
        bytes calldata _data,      // New Data
        string calldata _metadata, // New metadata
        bytes memory _signature    // Signature, generated in the previous step
    ) external payable checkEmitter(_emitterId)
}

Revoking SID

To revoke a SID you need only id of the SID you want to revoke. You should call revoke function on SingleIdentifierRegistry contract from your emitter wallet.

While registering and updating could be performed on any chain where your emitter was registered, revoking can be done only on the chain where you registered a schema.

contract SingleIdentifierRegistry {
    function revoke(
        bytes32 _sidId // Id of the SID you want to revoke
    ) public
}

Last updated