Access Condition Contracts

By developing VWBL access condition contracts, VWBL can support just about any on-chain access condition

Granting access control and registering access conditions

VWBL Gateway Smart Contracts expose the grantAccessControlAPI for granting access control features and for registering on-chain access conditions of digital content.

/**
 * @notice Register access conditions for digital content
 * @param documentId Id of digital content
 * @param conditionContractAddress Contract address which is defined access condition logic
 * @param minter Digital content creator address
 */
function grantAccessControl(
    bytes32 documentId, 
    address conditionContractAddress,
    address minter
) external payable;

Verify whether a key requester has access rights

The hasAccessControl API returns whether or not the user has access rights to the digital content or is the digital content creator. The VWBL Network calls this function to verify the following:

  • If the decryption key requester has access right of digital content
  • If the decryption key sender is digital content content creator (decryption key creator)
/**
 * @notice Returns True if user has access rights of digital content or digital content creator
 *         This function is called by VWBL Network (Decryption key management network)
 * @param user The address of decryption key requester or decryption key sender to VWBL Network
 * @param documentId The Identifier of digital content and decryption key
 */
function hasAccessControl(
    address user, 
    bytes32 documentId
) external view returns (bool) {
    ...
    IAccessControlChecker checker = IAccessControlChecker(accessConditionContractAddress);
    bool isPaidUser = paidUsers[documentId][user] || feeWei == 0;
    bool isOwner = checker.getOwnerAddress(documentId) == user;
    bool isMinter = checker.getMinterAddress(documentId) == user;
    bool hasAccess = checker.checkAccessControl(user, documentId);
    return  isOwner || isMinter || (isPaidUser && hasAccess);
}

Access condition contracts

Smart contracts can become VWBL access condition contracts by inheriting AbstractControlChecker.sol and exposing the 2 methods for the gateway contract.

AbstractControlChecker.sol:

VWBL Network gets the contract address which set Sign Message from the documentIdToToken.

abstract contract AbstractControlChecker is IAccessControlChecker {
    struct Token {
        // contract address which set Sign Message
        address contractAddress;
        uint256 tokenId;
    }
    mapping(bytes32 => Token) public documentIdToToken;
}

IAccessControlChecker.sol:

AbstractControlChecker contract inherits IAccessControlChecler interface.

  1. getOwnerAddress() : Returns the digital content owner address. There is only one digital content owner for each digital content and content owner can be transferred.
  2. checkAccessControl() : Returns whether user has access right of digital content.
interface IAccessControlChecker {
    /**
     * @dev Return owner address of document id
     * @param documentId The Identifier of digital content and decryption key
     * @return owner address
     */
    function getOwnerAddress(
        bytes32 documentId
    ) external view returns (address);
​

    /**
     * @dev Return whether user has access right of digital content
     *      This function is called by VWBLGateway contract
     * @param user The address of decryption key requester or decryption key sender to VWBL Network
     * @param documentId The Identifier of digital content and decryption key
     * @return True if user has access rights of digital content
     */
    function checkAccessControl(address user, bytes32 documentId) external view returns (bool);
​
}

results matching ""

    No results matching ""