Licensing
License Types
Authorizer.sol

Authorizer

A license which allows for the combination of several licenses via a boolean expression.

The contract stores the expression in abstract syntax tree (AST).

Configuration Functions

setAuth(bytes32 id, string calldata expression, address[] calldata authContracts)

Sets the boolean expression used to evaluate multiple licenses for a single node.

  • id: The node for which this expression is applied.
  • expression: A string defining the boolean expression of licenses. This made up of the following characters
    • ( Left bracket.
    • ) Right bracket.
    • & AND operation.
    • ! NOT operation.
    • | OR operation.
  • authContracts: an ordered list of licenses which are being used in the expression.

Example Expression:

string memory expression = "((0|1)&(!1)|(0|1))";
address[] authContracts = new address[](2);
authContracts[0] = address(public);
authContracts[1] = address(private);

With:

  • 0: being the public license, i.e true
  • 1: being the private license, i.e false

The expression is equal to ( (T|F) & !(F) | (T|F)) or simplified to ( T & T & T) = T.

Access Functions

getRoot(bytes32 id)

Returns the root node of the AST expression for a given ContentGraph node, made up of a operator, address of a license and the ids of child AST nodes.

getNode(uint256 id)

Returns a node in the AST expression tree, made up of a operator, address of a license and the ids of child AST nodes.

auth(bytes32 id, address user)

Returns the result of evaluating the expression set for a given node for a given user.

See Smart Contracts for the address of this license.