Skip to main content

Solidity API

TestDisputeManager

accept

mapping(bytes32 => bool) accept

accepted

function accepted(address provider, address buyer, bytes32 orig, bytes32 crypted) public view returns (bool)

setAccepted

function setAccepted(bytes32 orig, bytes32 crypted, address provider, address buyer) public

Common

getCurrentBlockNumber

function getCurrentBlockNumber() external view returns (uint256)

getCurrentBlockNumber get block number

NameTypeDescription
[0]uint256the current block number

isContract

function isContract(address addr) public view returns (bool)

isContract detect whether the address is is a contract address or externally owned account

NameTypeDescription
[0]booltrue if it is a contract address

provenanceSignatureIsCorrect

function provenanceSignatureIsCorrect(address _agentId, bytes32 _hash, bytes _signature) public pure returns (bool)
NameTypeDescription
_agentIdaddressThe address of the agent
_hashbytes32bytes32 message, the hash is the signed message. What is recovered is the signer address.
_signaturebytesSignatures provided by the agent
NameTypeDescription
[0]booltrue if the signature correspond to the agent address

calculateTotalAmount

function calculateTotalAmount(uint256[] _amounts) public pure returns (uint256)

Sum the total amount given an uint array

NameTypeDescription
[0]uint256the total amount

addressToBytes32

function addressToBytes32(address _addr) public pure returns (bytes32)

bytes32ToAddress

function bytes32ToAddress(bytes32 _b32) public pure returns (address)

Dispenser

tokenRequests

mapping(address => uint256) tokenRequests

totalMintAmount

uint256 totalMintAmount

maxAmount

uint256 maxAmount

maxMintAmount

uint256 maxMintAmount

minPeriod

uint256 minPeriod

scale

uint256 scale

token

contract NeverminedToken token

RequestFrequencyExceeded

event RequestFrequencyExceeded(address requester, uint256 minPeriod)

RequestLimitExceeded

event RequestLimitExceeded(address requester, uint256 amount, uint256 maxAmount)

isValidAddress

modifier isValidAddress(address _address)

initialize

function initialize(address _tokenAddress, address _owner) external

Dispenser Initializer

NameTypeDescription
_tokenAddressaddressThe deployed contract address of an ERC20
_owneraddressThe owner of the Dispenser Runs only on initial contract creation.

requestTokens

function requestTokens(uint256 amount) external returns (bool tokensTransferred)

user can request some tokens for testing

NameTypeDescription
amountuint256the amount of tokens to be requested
NameTypeDescription
tokensTransferredboolBoolean indication of tokens are requested

setMinPeriod

function setMinPeriod(uint256 period) external

the Owner can set the min period for token requests

NameTypeDescription
perioduint256the min amount of time before next request

setMaxAmount

function setMaxAmount(uint256 amount) external

the Owner can set the max amount for token requests

NameTypeDescription
amountuint256the max amount of tokens that can be requested

setMaxMintAmount

function setMaxMintAmount(uint256 amount) external

the Owner can set the max amount for token requests

NameTypeDescription
amountuint256the max amount of tokens that can be requested

HashLists

Hash lists contract is a sample list contract in which uses HashListLibrary.sol in order to store, retrieve, remove, and update bytes32 values in hash lists. This is a reference implementation for IList interface. It is used for whitelisting condition. Any entity can have its own implementation of the interface in which could be used for the same condition.

lists

mapping(bytes32 => struct HashListLibrary.List) lists

initialize

function initialize(address _owner) public

HashLists Initializer

NameTypeDescription
_owneraddressThe owner of the hash list Runs only upon contract creation.

hash

function hash(address account) public pure returns (bytes32)

hash ethereum accounts

NameTypeDescription
accountaddressEthereum address
NameTypeDescription
[0]bytes32bytes32 hash of the account

add

function add(bytes32[] values) external returns (bool)

put an array of elements without indexing this meant to save gas in case of large arrays

NameTypeDescription
valuesbytes32[]is an array of elements value
NameTypeDescription
[0]booltrue if values are added successfully

add

function add(bytes32 value) external returns (bool)

add indexes an element then adds it to a list

NameTypeDescription
valuebytes32is a bytes32 value
NameTypeDescription
[0]booltrue if value is added successfully

update

function update(bytes32 oldValue, bytes32 newValue) external returns (bool)

update the value with a new value and maintain indices

NameTypeDescription
oldValuebytes32is an element value in a list
newValuebytes32new value
NameTypeDescription
[0]booltrue if value is updated successfully

index

function index(uint256 from, uint256 to) external returns (bool)

index is used to map each element value to its index on the list

NameTypeDescription
fromuint256index is where to 'from' indexing in the list
touint256index is where to stop indexing
NameTypeDescription
[0]booltrue if the sub list is indexed

has

function has(bytes32 id, bytes32 value) external view returns (bool)

has checks whether a value is exist

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
valuebytes32is element value in list
NameTypeDescription
[0]booltrue if the value exists

has

function has(bytes32 value) external view returns (bool)

has checks whether a value is exist

NameTypeDescription
valuebytes32is element value in list
NameTypeDescription
[0]booltrue if the value exists

remove

function remove(bytes32 value) external returns (bool)

remove value from a list, updates indices, and list size

NameTypeDescription
valuebytes32is an element value in a list
NameTypeDescription
[0]booltrue if value is removed successfully

get

function get(bytes32 id, uint256 _index) external view returns (bytes32)

has value by index

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
_indexuint256is where is value is stored in the list
NameTypeDescription
[0]bytes32the value if exists

size

function size(bytes32 id) external view returns (uint256)

size gets the list size

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]uint256total length of the list

all

function all(bytes32 id) external view returns (bytes32[])

all returns all list elements

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]bytes32[]all list elements

indexOf

function indexOf(bytes32 id, bytes32 value) external view returns (uint256)

indexOf gets the index of a value in a list

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
valuebytes32is element value in list
NameTypeDescription
[0]uint256value index in list

ownedBy

function ownedBy(bytes32 id) external view returns (address)

ownedBy gets the list owner

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]addresslist owner

isIndexed

function isIndexed(bytes32 id) external view returns (bool)

isIndexed checks if the list is indexed

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]booltrue if the list is indexed

NeverminedToken

Implementation of a Test Token. Test Token is an ERC20 token only for testing purposes

initialize

function initialize(address _owner, address payable _initialMinter) public

NeverminedToken Initializer Runs only on initial contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract
_initialMinteraddress payableis the first token minter added

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 amount) internal

_See {ERC20-_beforeTokenTransfer}.

Requirements:

  • minted tokens must not cause the total supply to go over the cap._

mint

function mint(address account, uint256 amount) external returns (bool)

_Creates amount tokens and assigns them to account, increasing the total supply.

Emits a {Transfer} event with from set to the zero address.

Requirements:

  • to cannot be the zero address._

AgreementStoreLibrary

Implementation of the Agreement Store Library. The agreement store library holds the business logic in which manages the life cycle of SEA agreement, each agreement is linked to the DID of an asset, template, and condition IDs.

Agreement

struct Agreement {
bytes32 did;
address templateId;
bytes32[] conditionIds;
address lastUpdatedBy;
uint256 blockNumberUpdated;
}

AgreementList

struct AgreementList {
mapping(bytes32 => struct AgreementStoreLibrary.Agreement) agreements;
mapping(bytes32 => bytes32[]) didToAgreementIds;
mapping(address => bytes32[]) templateIdToAgreementIds;
bytes32[] agreementIds;
}

create

function create(struct AgreementStoreLibrary.AgreementList _self, bytes32 _id, bytes32, address _templateId, bytes32[]) internal

create new agreement checks whether the agreement Id exists, creates new agreement instance, including the template, conditions and DID.

NameTypeDescription
_selfstruct AgreementStoreLibrary.AgreementListis AgreementList storage pointer
_idbytes32agreement identifier
bytes32
_templateIdaddresstemplate identifier
bytes32[]

Template

getConditionTypes

function getConditionTypes() external view returns (address[])

AgreementStoreManager

_Implementation of the Agreement Store.

 The agreement store generates conditions for an agreement template.
Agreement templates must to be approved in the Template Store
Each agreement is linked to the DID of an asset._

PROXY_ROLE

bytes32 PROXY_ROLE

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

agreementList

struct AgreementStoreLibrary.AgreementList agreementList

state storage for the agreements

conditionStoreManager

contract ConditionStoreManager conditionStoreManager

templateStoreManager

contract TemplateStoreManager templateStoreManager

didRegistry

contract DIDRegistry didRegistry

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _templateStoreManagerAddress, address _didRegistryAddress) public

initialize AgreementStoreManager Initializer Initializes Ownable. Only on contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract
_conditionStoreManagerAddressaddressis the address of the connected condition store
_templateStoreManagerAddressaddressis the address of the connected template store
_didRegistryAddressaddressis the address of the connected DID Registry

fullConditionId

function fullConditionId(bytes32 _agreementId, address _condType, bytes32 _valueHash) public pure returns (bytes32)

agreementId

function agreementId(bytes32 _agreementId, address _creator) public pure returns (bytes32)

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, address[] _conditionTypes, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts) public

Create a new agreement. The agreement will create conditions of conditionType with conditionId. Only "approved" templates can access this function.

NameTypeDescription
_idbytes32is the ID of the new agreement. Must be unique.
_didbytes32is the bytes32 DID of the asset. The DID must be registered beforehand.
_conditionTypesaddress[]is a list of addresses that point to Condition contracts.
_conditionIdsbytes32[]is a list of bytes32 content-addressed Condition IDs
_timeLocksuint256[]is a list of uint time lock values associated to each Condition
_timeOutsuint256[]is a list of uint time out values associated to each Condition

CreateAgreementArgs

struct CreateAgreementArgs {
bytes32 _id;
bytes32 _did;
address[] _conditionTypes;
bytes32[] _conditionIds;
uint256[] _timeLocks;
uint256[] _timeOuts;
address _creator;
uint256 _idx;
address payable _rewardAddress;
address _tokenAddress;
uint256[] _amounts;
address[] _receivers;
}

createAgreementAndPay

function createAgreementAndPay(struct AgreementStoreManager.CreateAgreementArgs args) public payable

createAgreementAndFulfill

function createAgreementAndFulfill(bytes32 _id, bytes32 _did, address[] _conditionTypes, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address[] _account, uint256[] _idx, bytes[] params) public payable

getAgreementTemplate

function getAgreementTemplate(bytes32 _id) external view returns (address)

getDIDRegistryAddress

function getDIDRegistryAddress() public view virtual returns (address)

getDIDRegistryAddress utility function used by other contracts or any EOA.

NameTypeDescription
[0]addressthe DIDRegistry address

AccessCondition

_Implementation of the Access Condition

 Access Secret Store Condition is special condition
where a client or Parity secret store can encrypt/decrypt documents
based on the on-chain granted permissions. For a given DID
document, and agreement ID, the owner/provider of the DID
will fulfill the condition. Consequently secret store
will check whether the permission is granted for the consumer
in order to encrypt/decrypt the document._

CONDITION_TYPE

bytes32 CONDITION_TYPE

DocumentPermission

struct DocumentPermission {
bytes32 agreementIdDeprecated;
mapping(address => bool) permission;
}

documentPermissions

mapping(bytes32 => struct AccessCondition.DocumentPermission) documentPermissions

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

didRegistry

contract DIDRegistry didRegistry

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _documentId, address _grantee, bytes32 _conditionId)

onlyDIDOwnerOrProvider

modifier onlyDIDOwnerOrProvider(bytes32 _documentId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _agreementStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_agreementStoreManagerAddressaddressagreement store manager address

reinitialize

function reinitialize() external

Should be called when the contract has been upgraded.

hashValues

function hashValues(bytes32 _documentId, address _grantee) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill access secret store condition

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

grantPermission

function grantPermission(address _grantee, bytes32 _documentId) public

grantPermission is called only by DID owner or provider

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys

renouncePermission

function renouncePermission(address _grantee, bytes32 _documentId) public

renouncePermission is called only by DID owner or provider

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys

checkPermissions

function checkPermissions(address _grantee, bytes32 _documentId) external view returns (bool permissionGranted)

checkPermissions is called by Parity secret store

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
NameTypeDescription
permissionGrantedbooltrue if the access was granted

IDisputeManager

verifyProof

function verifyProof(bytes proof, uint256[] pubSignals) external view returns (bool)

AccessProofCondition

Implementation of the Access Condition with transfer proof. The idea is that the hash of the decryption key is known before hand, and the key matching this hash is passed from data provider to the buyer using this smart contract. Using ZK proof the key is kept hidden from outsiders. For the protocol to work, both the provider and buyer need to have public keys in the babyjub curve. To initiate the deal, buyer will pass the key hash and the public keys of participants. The provider needs to pass the cipher text encrypted using MIMC (symmetric encryption). The secret key for MIMC is computed using ECDH (requires one public key and one secret key for the curve). The hash function that is used is Poseidon.

CONDITION_TYPE

bytes32 CONDITION_TYPE

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

disputeManager

contract IDisputeManager disputeManager

Fulfilled

event Fulfilled(bytes32 _agreementId, uint256 _origHash, uint256[2] _buyer, uint256[2] _provider, uint256[2] _cipher, bytes _proof, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _agreementStoreManagerAddress, address _disputeManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_agreementStoreManagerAddressaddressagreement store manager address
_disputeManagerAddressaddressdispute manager address

changeDisputeManager

function changeDisputeManager(address _disputeManagerAddress) external

hashValues

function hashValues(uint256 _origHash, uint256[2] _buyer, uint256[2] _provider) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_origHashuint256is the hash of the key
_buyeruint256[2]buyer public key
_provideruint256[2]provider public key
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, uint256 _origHash, uint256[2] _buyer, uint256[2] _provider, uint256[2] _cipher, bytes _proof) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill key transfer

The key with hash _origHash is transferred to the _buyer from _provider.

NameTypeDescription
_agreementIdbytes32associated agreement
_origHashuint256is the hash of data to access
_buyeruint256[2]buyer public key
_provideruint256[2]provider public key
_cipheruint256[2]encrypted version of the key
_proofbytesSNARK proof that the cipher text can be decrypted by buyer to give the key with hash _origHash
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

ComputeExecutionCondition

Implementation of the Compute Execution Condition This condition is meant to be a signal in which triggers the execution of a compute service. The compute service is fully described in the associated DID document. The provider of the compute service will send this signal to its workers by fulfilling the condition where they are listening to the fulfilled event.

CONDITION_TYPE

bytes32 CONDITION_TYPE

computeExecutionStatus

mapping(bytes32 => mapping(address => bool)) computeExecutionStatus

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _computeConsumer, bytes32 _conditionId)

onlyDIDOwnerOrProvider

modifier onlyDIDOwnerOrProvider(bytes32 _did)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _agreementStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_agreementStoreManagerAddressaddressagreement store manager address

hashValues

function hashValues(bytes32 _did, address _computeConsumer) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32Decentralized Identifier (unique compute/asset resolver) describes the compute service
_computeConsumeraddressis the consumer's address
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _computeConsumer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill compute execution condition

only the compute provider can fulfill this condition. By fulfilling this condition the compute provider will trigger the execution of the offered job/compute. The compute service is described in a DID document.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32Decentralized Identifier (unique compute/asset resolver) describes the compute service
_computeConsumeraddressis the consumer's address
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

wasComputeTriggered

function wasComputeTriggered(bytes32 _did, address _computeConsumer) public view returns (bool)

wasComputeTriggered checks whether the compute is triggered or not.

NameTypeDescription
_didbytes32Decentralized Identifier (unique compute/asset resolver) describes the compute service
_computeConsumeraddressis the compute consumer's address
NameTypeDescription
[0]booltrue if the compute is triggered

Condition

_Implementation of the Condition

 Each condition has a validation function that returns either FULFILLED, 
ABORTED or UNFULFILLED. When a condition is successfully solved, we call
it FULFILLED. If a condition cannot be FULFILLED anymore due to a timeout
or other types of counter-proofs, the condition is ABORTED. UNFULFILLED
values imply that a condition has not been provably FULFILLED or ABORTED.
All initialized conditions start out as UNFULFILLED._

conditionStoreManager

contract ConditionStoreManager conditionStoreManager

generateId

function generateId(bytes32 _agreementId, bytes32 _valueHash) public view returns (bytes32)

generateId condition Id from the following parameters

NameTypeDescription
_agreementIdbytes32SEA agreement ID
_valueHashbytes32hash of all the condition input values

fulfill

function fulfill(bytes32 _id, enum ConditionStoreLibrary.ConditionState _newState) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfill set the condition state to Fulfill | Abort

NameTypeDescription
_idbytes32condition identifier
_newStateenum ConditionStoreLibrary.ConditionStatenew condition state (Fulfill/Abort)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatethe updated condition state

abortByTimeOut

function abortByTimeOut(bytes32 _id) external returns (enum ConditionStoreLibrary.ConditionState)

abortByTimeOut set condition state to Aborted if the condition is timed out

NameTypeDescription
_idbytes32condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatethe updated condition state

ConditionStoreLibrary

_Implementation of the Condition Store Library.

 Condition is a key component in the service execution agreement. 
This library holds the logic for creating and updating condition
Any Condition has only four state transitions starts with Uninitialized,
Unfulfilled, Fulfilled, and Aborted. Condition state transition goes only
forward from Unintialized -> Unfulfilled -> {Fulfilled || Aborted}_

ConditionState

enum ConditionState {
Uninitialized,
Unfulfilled,
Fulfilled,
Aborted
}

Condition

struct Condition {
address typeRef;
enum ConditionStoreLibrary.ConditionState state;
address createdBy;
address lastUpdatedBy;
uint256 blockNumberUpdated;
}

ConditionList

struct ConditionList {
mapping(bytes32 => struct ConditionStoreLibrary.Condition) conditions;
mapping(bytes32 => mapping(bytes32 => bytes32)) map;
bytes32[] conditionIds;
}

create

function create(struct ConditionStoreLibrary.ConditionList _self, bytes32 _id, address _typeRef) internal

create new condition

check whether the condition exists, assigns condition type, condition state, last updated by, and update at (which is the current block number)

NameTypeDescription
_selfstruct ConditionStoreLibrary.ConditionListis the ConditionList storage pointer
_idbytes32valid condition identifier
_typeRefaddresscondition contract address

updateState

function updateState(struct ConditionStoreLibrary.ConditionList _self, bytes32 _id, enum ConditionStoreLibrary.ConditionState _newState) internal

updateState update the condition state

check whether the condition state transition is right, assign the new state, update last updated by and updated at.

NameTypeDescription
_selfstruct ConditionStoreLibrary.ConditionListis the ConditionList storage pointer
_idbytes32condition identifier
_newStateenum ConditionStoreLibrary.ConditionStatethe new state of the condition

updateKeyValue

function updateKeyValue(struct ConditionStoreLibrary.ConditionList _self, bytes32 _id, bytes32 _key, bytes32 _value) internal

ConditionStoreManager

_Implementation of the Condition Store Manager.

 Condition store manager is responsible for enforcing the 
the business logic behind creating/updating the condition state
based on the assigned role to each party. Only specific type of
contracts are allowed to call this contract, therefore there are
two types of roles, create role that in which is able to create conditions.
The second role is the update role, which is can update the condition state.
Also, it support delegating the roles to other contract(s)/account(s)._

PROXY_ROLE

bytes32 PROXY_ROLE

RoleType

enum RoleType {
Create,
Update
}

createRole

address createRole

conditionList

struct ConditionStoreLibrary.ConditionList conditionList

epochList

struct EpochLibrary.EpochList epochList

nvmConfigAddress

address nvmConfigAddress

ConditionCreated

event ConditionCreated(bytes32 _id, address _typeRef, address _who)

ConditionUpdated

event ConditionUpdated(bytes32 _id, address _typeRef, enum ConditionStoreLibrary.ConditionState _state, address _who)

onlyCreateRole

modifier onlyCreateRole()

onlyUpdateRole

modifier onlyUpdateRole(bytes32 _id)

onlyValidType

modifier onlyValidType(address typeRef)

initialize

function initialize(address _creator, address _owner, address _nvmConfigAddress) public

initialize ConditionStoreManager Initializer Initialize Ownable. Only on contract creation,

NameTypeDescription
_creatoraddressrefers to the creator of the contract
_owneraddressrefers to the owner of the contract
_nvmConfigAddressaddressrefers to the contract address of NeverminedConfig

getCreateRole

function getCreateRole() external view returns (address)

getCreateRole get the address of contract which has the create role

NameTypeDescription
[0]addresscreate condition role address

getNvmConfigAddress

function getNvmConfigAddress() external view returns (address)

getNvmConfigAddress get the address of the NeverminedConfig contract

NameTypeDescription
[0]addressNeverminedConfig contract address

setNvmConfigAddress

function setNvmConfigAddress(address _addr) external

delegateCreateRole

function delegateCreateRole(address delegatee) external

delegateCreateRole only owner can delegate the create condition role to a different address

NameTypeDescription
delegateeaddressdelegatee address

delegateUpdateRole

function delegateUpdateRole(bytes32 _id, address delegatee) external

delegateUpdateRole only owner can delegate the update role to a different address for specific condition Id which has the create role

NameTypeDescription
_idbytes32
delegateeaddressdelegatee address

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

createCondition

function createCondition(bytes32 _id, address _typeRef) external

createCondition only called by create role address the condition should use a valid condition contract address, valid time lock and timeout. Moreover, it enforce the condition state transition from Uninitialized to Unfulfilled.

NameTypeDescription
_idbytes32unique condition identifier
_typeRefaddresscondition contract address

createCondition2

function createCondition2(bytes32 _id, address _typeRef) external

createCondition

function createCondition(bytes32 _id, address _typeRef, uint256 _timeLock, uint256 _timeOut) public

createCondition only called by create role address the condition should use a valid condition contract address, valid time lock and timeout. Moreover, it enforce the condition state transition from Uninitialized to Unfulfilled.

NameTypeDescription
_idbytes32unique condition identifier
_typeRefaddresscondition contract address
_timeLockuint256start of the time window
_timeOutuint256end of the time window

updateConditionState

function updateConditionState(bytes32 _id, enum ConditionStoreLibrary.ConditionState _newState) external returns (enum ConditionStoreLibrary.ConditionState)

updateConditionState only called by update role address. It enforce the condition state transition to either Fulfill or Aborted state

NameTypeDescription
_idbytes32unique condition identifier
_newStateenum ConditionStoreLibrary.ConditionState
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatethe current condition state

updateConditionMapping

function updateConditionMapping(bytes32 _id, bytes32 _key, bytes32 _value) external

updateConditionMappingProxy

function updateConditionMappingProxy(bytes32 _id, bytes32 _key, bytes32 _value) external

getCondition

function getCondition(bytes32 _id) external view returns (address typeRef, enum ConditionStoreLibrary.ConditionState state, uint256 timeLock, uint256 timeOut, uint256 blockNumber)

getCondition

NameTypeDescription
typeRefaddressthe type reference
stateenum ConditionStoreLibrary.ConditionStatecondition state
timeLockuint256the time lock
timeOutuint256time out
blockNumberuint256block number

getConditionState

function getConditionState(bytes32 _id) external view virtual returns (enum ConditionStoreLibrary.ConditionState)

getConditionState

NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

getConditionTypeRef

function getConditionTypeRef(bytes32 _id) external view virtual returns (address)

getConditionTypeRef

NameTypeDescription
[0]addresscondition typeRef

getMappingValue

function getMappingValue(bytes32 _id, bytes32 _key) external view virtual returns (bytes32)

getConditionState

NameTypeDescription
[0]bytes32condition state

isConditionTimeLocked

function isConditionTimeLocked(bytes32 _id) public view returns (bool)

isConditionTimeLocked

NameTypeDescription
[0]boolwhether the condition is timedLock ended

isConditionTimedOut

function isConditionTimedOut(bytes32 _id) public view returns (bool)

isConditionTimedOut

NameTypeDescription
[0]boolwhether the condition is timed out

HashLockCondition

Implementation of the Hash Lock Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(uint256 _preimage) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_preimageuint256refers uint value of the hash pre-image.
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(string _preimage) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_preimagestringrefers string value of the hash pre-image.
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _preimage) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_preimagebytes32refers bytes32 value of the hash pre-image.
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, uint256 _preimage) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the condition by calling check the the hash and the pre-image uint value

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_preimageuint256
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfill

function fulfill(bytes32 _agreementId, string _preimage) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the condition by calling check the the hash and the pre-image string value

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_preimagestring
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfill

function fulfill(bytes32 _agreementId, bytes32 _preimage) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the condition by calling check the the hash and the pre-image bytes32 value

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_preimagebytes32
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

_fulfill

function _fulfill(bytes32 _generatedId) private returns (enum ConditionStoreLibrary.ConditionState)

_fulfill calls super fulfil method

NameTypeDescription
_generatedIdbytes32SEA agreement identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

ICondition

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes params) external payable

ILockPayment

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId, address _rewardAddress, address _tokenAddress, address[] _receivers, uint256[] _amounts)

hashValues

function hashValues(bytes32 _did, address _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_rewardAddressaddressthe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external payable returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires valid token transfer in order to lock the amount of tokens based on the SEA

NameTypeDescription
_agreementIdbytes32the agreement identifier
_didbytes32the asset decentralized identifier
_rewardAddressaddress payablethe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment.
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

LockPaymentCondition

Implementation of the Lock Payment Condition This condition allows to lock payment for multiple receivers taking into account the royalties to be paid to the original creators in a secondary market.

didRegistry

contract DIDRegistry didRegistry

nvmConfig

contract INVMConfig nvmConfig

CONDITION_TYPE

bytes32 CONDITION_TYPE

KEY_ASSET_RECEIVER

bytes32 KEY_ASSET_RECEIVER

PROXY_ROLE

bytes32 PROXY_ROLE

ALLOWED_EXTERNAL_CONTRACT_ROLE

bytes32 ALLOWED_EXTERNAL_CONTRACT_ROLE

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

grantExternalContractRole

function grantExternalContractRole(address _address) public

revokeExternalContractRole

function revokeExternalContractRole(address _address) public

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address

reinitialize

function reinitialize() external

Should be called when the contract has been upgraded.

hashValues

function hashValues(bytes32 _did, address _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_rewardAddressaddressthe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external payable returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires valid token transfer in order to lock the amount of tokens based on the SEA

NameTypeDescription
_agreementIdbytes32the agreement identifier
_didbytes32the asset decentralized identifier
_rewardAddressaddress payablethe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment.
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfillExternal

function fulfillExternal(bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _externalContract, bytes32 _remoteId, uint256[] _amounts, address[] _receivers) external payable returns (enum ConditionStoreLibrary.ConditionState)

fulfill lock condition using the funds locked in an external contract (auction, bonding curve, lottery, etc)

NameTypeDescription
_agreementIdbytes32the agreement identifier
_didbytes32the asset decentralized identifier
_rewardAddressaddress payablethe contract address where the reward is locked
_externalContractaddressthe address of the contract with the lock funds are locked
_remoteIdbytes32the id used to identify into the external contract
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

encodeParams

function encodeParams(bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external pure returns (bytes)

fulfillInternal

function fulfillInternal(address _account, bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes params) external payable

_transferERC20Proxy

function _transferERC20Proxy(address _senderAddress, address _rewardAddress, address _tokenAddress, uint256 _amount) internal

_transferERC20Proxy transfer ERC20 tokens

Will throw if transfer fails

NameTypeDescription
_senderAddressaddressthe address to send the tokens from
_rewardAddressaddressthe address to receive the tokens
_tokenAddressaddressthe ERC20 contract address to use during the payment
_amountuint256token amount to be locked/released

_transferETH

function _transferETH(address payable _rewardAddress, uint256 _amount) internal

_transferETH transfer ETH

NameTypeDescription
_rewardAddressaddress payablethe address to receive the ETH
_amountuint256ETH amount to be locked/released

allowedExternalContract

modifier allowedExternalContract(address _externalContractAddress)

areMarketplaceFeesIncluded

function areMarketplaceFeesIncluded(uint256[] _amounts, address[] _receivers) internal view returns (bool)

DistributeNFTCollateralCondition

Implementation of a condition allowing to transfer a NFT to an account or another depending on the final state of a lock condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

aaveCreditVault

contract AaveCreditVault aaveCreditVault

_lockConditionAddress

address _lockConditionAddress

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _receiver, bytes32 _conditionId, address _contract)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _lockNFTConditionAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_lockNFTConditionAddressaddressLock NFT Condition address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _nftContractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_vaultAddressaddressThe contract address of the vault
_nftContractAddressaddressNFT contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _nftContractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_vaultAddressaddressThe contract address of the vault
_nftContractAddressaddressNFT contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

INFTAccess

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _documentId, address _grantee, bytes32 _conditionId)

hashValues

function hashValues(bytes32 _documentId, address _grantee, address _contractAddress) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee, address _contractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill NFT Access conditions

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

INFTHolder

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _address, bytes32 _conditionId, uint256 _amount)

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

INFTLock

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _lockAddress, bytes32 _conditionId, uint256 _amount, address _receiver, address _nftContractAddress)

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the NFTs locked
_nftContractAddressaddressIs the address of the NFT (ERC-721, ERC-1155) contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesMarked

function hashValuesMarked(bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) external pure returns (bytes32)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillMarked

function fulfillMarked(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

ITransferNFT

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _receiver, uint256 _amount, bytes32 _conditionId, address _contract)

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition, address _contract, bool _transfer) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
_contractaddress
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _contract, bool _transfer) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_contractaddress
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

getNFTDefaultAddress

function getNFTDefaultAddress() external view returns (address)

returns if the default NFT contract address

The default NFT contract address was given to the Transfer Condition during the contract initialization

NameTypeDescription
[0]addressthe NFT contract address used by default in the transfer condition

NFT721HolderCondition

Implementation of the Nft Holder Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

NFT721LockCondition

Implementation of the NFT Lock Condition for ERC-721 based NFTs

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesMarked

function hashValuesMarked(bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public pure returns (bytes32)

fulfillMarked

function fulfillMarked(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method lock a NFT into the _lockAddress.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens (1)
_receiveraddress
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

onERC721Received

function onERC721Received(address, address, uint256, bytes) public virtual returns (bytes4)

Always returns IERC721Receiver.onERC721Received.selector.

NFTAccessCondition

_Implementation of the Access Condition specific for NFTs

 NFT Access Condition is special condition used to give access 
to a specific NFT related to a DID._

CONDITION_TYPE

bytes32 CONDITION_TYPE

DocumentPermission

struct DocumentPermission {
bytes32 agreementIdDeprecated;
mapping(address => bool) permission;
}

nftPermissions

mapping(bytes32 => struct NFTAccessCondition.DocumentPermission) nftPermissions

didRegistry

contract DIDRegistry didRegistry

onlyDIDOwnerOrProvider

modifier onlyDIDOwnerOrProvider(bytes32 _documentId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID registry address

hashValues

function hashValues(bytes32 _documentId, address _grantee) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _documentId, address _grantee, address _contractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill NFT Access condition

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee, address _contractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill NFT Access condition

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddressis the contract address of the NFT implementation (ERC-1155 or ERC-721)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

grantPermission

function grantPermission(address _grantee, bytes32 _documentId) public

grantPermission is called only by DID owner or provider

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys

checkPermissions

function checkPermissions(address _grantee, bytes32 _documentId) external view returns (bool permissionGranted)

checkPermissions is called to validate the permissions of user related to the NFT attached to an asset

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID
NameTypeDescription
permissionGrantedbooltrue if the access was granted

NFTHolderCondition

Implementation of the Nft Holder Condition

erc1155

contract ERC1155BurnableUpgradeable erc1155

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _ercAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_ercAddressaddressNevermined ERC-1155 address

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

NFTLockCondition

Implementation of the NFT Lock Condition

erc1155

contract IERC1155Upgradeable erc1155

CONDITION_TYPE

bytes32 CONDITION_TYPE

ERC1155_ACCEPTED

bytes4 ERC1155_ACCEPTED

ERC1155_BATCH_ACCEPTED

bytes4 ERC1155_BATCH_ACCEPTED

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _ercAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_ercAddressaddressNevermined ERC-1155 address

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-1155) contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesMarked

function hashValuesMarked(bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public pure returns (bytes32)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _nft) public returns (enum ConditionStoreLibrary.ConditionState)

fulfillMarked

function fulfillMarked(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_receiveraddress
_nftContractAddressaddressIs the address of the NFT (ERC-1155) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

onERC1155Received

function onERC1155Received(address, address, uint256, uint256, bytes) external pure returns (bytes4)

onERC1155BatchReceived

function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) external pure returns (bytes4)

supportsInterface

function supportsInterface(bytes4 interfaceId) external pure returns (bool)

_Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created.

This function call must use less than 30 000 gas._

TransferNFT721Condition

Implementation of condition allowing to transfer an NFT between the original owner and a receiver

CONDITION_TYPE

bytes32 CONDITION_TYPE

MARKET_ROLE

bytes32 MARKET_ROLE

erc721

contract NFT721Upgradeable erc721

_lockConditionAddress

address _lockConditionAddress

PROXY_ROLE

bytes32 PROXY_ROLE

didRegistry

contract DIDRegistry didRegistry

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress, address _ercAddress, address _lockNFTConditionAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address
_ercAddressaddressNevermined ERC-721 address
_lockNFTConditionAddressaddress

getNFTDefaultAddress

function getNFTDefaultAddress() external view returns (address)

returns if the default NFT contract address

The default NFT contract address was given to the Transfer Condition during the contract initialization

NameTypeDescription
[0]addressthe NFT contract address used by default in the transfer condition

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition, address _contract, bool _transfer) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
_contractaddressNFT contract to use
_transferbool
NameTypeDescription
[0]bytes32bytes32 hash of all these values

encodeParams

function encodeParams(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) external pure returns (bytes)

Encodes/serialize all the parameters received

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressthe NFT contract to use
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]bytesthe encoded parameters

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _contract, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_contractaddressNFT contract to use
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes _params) external payable

fulfill the transfer NFT condition by a proxy

Fulfill method transfer a certain amount of NFTs

NameTypeDescription
_accountaddressNFT Holder
_agreementIdbytes32agreement identifier
_paramsbytesencoded parameters

fulfillInternal

function fulfillInternal(address _account, bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _contract, bool _transfer, uint256 _expirationBlock) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, bool _transfer, address _nftContractAddress, uint256 _expirationBlock) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_transferboolif yes it does a transfer if false it mints the NFT
_nftContractAddressaddressthe address of the ERC-721 NFT contract
_expirationBlockuint256in which block the nft expires, if 0 it doesn't expire
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

TransferNFTCondition

Implementation of condition allowing to transfer an NFT between the original owner and a receiver

CONDITION_TYPE

bytes32 CONDITION_TYPE

MARKET_ROLE

bytes32 MARKET_ROLE

erc1155

contract NFTUpgradeable erc1155

didRegistry

contract DIDRegistry didRegistry

PROXY_ROLE

bytes32 PROXY_ROLE

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress, address _ercAddress, address _nftContractAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address
_ercAddressaddressNevermined ERC-1155 address
_nftContractAddressaddressMarket address

grantMarketRole

function grantMarketRole(address _nftContractAddress) public

revokeMarketRole

function revokeMarketRole(address _nftContractAddress) public

getNFTDefaultAddress

function getNFTDefaultAddress() external view returns (address)

returns if the default NFT contract address

The default NFT contract address was given to the Transfer Condition during the contract initialization

NameTypeDescription
[0]addressthe NFT contract address used by default in the transfer condition

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition, address _nftContractAddress, bool _transfer) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
_nftContractAddressaddressNFT contract to use
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition) public returns (enum ConditionStoreLibrary.ConditionState)

encodeParams

function encodeParams(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) external pure returns (bytes)

Encodes/serialize all the parameters received

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressthe NFT contract to use
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]bytesthe encoded parameters

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes _params) external payable

fulfill the transfer NFT condition by a proxy

Fulfill method transfer a certain amount of NFTs

NameTypeDescription
_accountaddressNFT Holder
_agreementIdbytes32agreement identifier
_paramsbytesencoded parameters

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressNFT contract to use
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillInternal

function fulfillInternal(address _account, bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressthe address of the ERC-721 NFT contract
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

SignCondition

Implementation of the Sign Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _message, address _publicKey) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_messagebytes32the message to be signed
_publicKeyaddressthe public key of the signing address
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _message, address _publicKey, bytes _signature) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill validate the signed message and fulfill the condition

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_messagebytes32the message to be signed
_publicKeyaddressthe public key of the signing address
_signaturebytessignature of the signed message using the public key
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

ThresholdCondition

_Implementation of the Threshold Condition

 Threshold condition acts as a filter for a set of input condition(s) in which sends 
a signal whether to complete the flow execution or abort it. This type of conditions
works as intermediary conditions where they wire SEA conditions in order to support
more complex scenarios._

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32[] inputConditions, uint256 threshold) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
inputConditionsbytes32[]array of input conditions IDs
thresholduint256the required number of fulfilled input conditions
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32[] _inputConditions, uint256 threshold) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill threshold condition

the fulfill method check whether input conditions are fulfilled or not.

NameTypeDescription
_agreementIdbytes32agreement identifier
_inputConditionsbytes32[]array of input conditions IDs
thresholduint256the required number of fulfilled input conditions
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

canFulfill

function canFulfill(bytes32[] _inputConditions, uint256 threshold) private view returns (bool _fulfill)

canFulfill check if condition can be fulfilled

NameTypeDescription
_inputConditionsbytes32[]array of input conditions IDs
thresholduint256the required number of fulfilled input conditions
NameTypeDescription
_fulfillbooltrue if can fulfill

TransferDIDOwnershipCondition

Implementation of condition allowing to transfer the ownership between the original owner and a receiver

CONDITION_TYPE

bytes32 CONDITION_TYPE

didRegistry

contract DIDRegistry didRegistry

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _receiver, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address

hashValues

function hashValues(bytes32 _did, address _receiver) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_receiveraddressis the address of the granted user or the DID provider
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _receiver) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer DID ownership condition

only DID owner or DID provider can call this method. Fulfill method transfer full ownership permissions to to _receiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_receiveraddressis the address of the granted user
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

WhitelistingCondition

Implementation of the Whitelisting Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(address _listAddress, bytes32 _item) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_listAddressaddresslist contract address
_itembytes32item in the list
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, address _listAddress, bytes32 _item) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill check whether address is whitelisted in order to fulfill the condition. This method will be called by any one in this whitelist.

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_listAddressaddresslist contract address
_itembytes32item in the list
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

AaveBorrowCondition

Implementation of the Aave Borrow Credit Condition

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _assetToBorrow, uint256 _amount, uint256 _interestRateMode) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToBorrowaddressthe address of the asset to borrow (i.e DAI)
_amountuint256the amount of the ERC-20 the assets to borrow (i.e 50 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _assetToBorrow, uint256 _amount, uint256 _interestRateMode) external returns (enum ConditionStoreLibrary.ConditionState)

It allows the borrower to borrow the asset deposited by the lender

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToBorrowaddressthe address of the asset to borrow (i.e DAI)
_amountuint256the amount of the ERC-20 the assets to borrow (i.e 50 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

AaveCollateralDepositCondition

Implementation of the Aave Collateral Deposit Condition This condition allows a Lender to deposit the collateral that into account the royalties to be paid to the original creators in a secondary market.

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _collateralAsset, uint256 _collateralAmount, address _delegatedAsset, uint256 _delegatedAmount, uint256 _interestRateMode) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the ERC-20 that will be used as collateral (i.e WETH)
_collateralAmountuint256the amount of the ERC-20 that will be used as collateral (i.e 10 WETH)
_delegatedAssetaddressthe address of the ERC-20 that will be delegated to the borrower (i.e DAI)
_delegatedAmountuint256the amount of the ERC-20 that will be delegated to the borrower (i.e 500 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _collateralAsset, uint256 _collateralAmount, address _delegatedAsset, uint256 _delegatedAmount, uint256 _interestRateMode) external payable returns (enum ConditionStoreLibrary.ConditionState)

It fulfills the condition if the collateral can be deposited into the vault

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the ERC-20 that will be used as collateral (i.e WETH)
_collateralAmountuint256the amount of the ERC-20 that will be used as collateral (i.e 10 WETH)
_delegatedAssetaddressthe address of the ERC-20 that will be delegated to the borrower (i.e DAI)
_delegatedAmountuint256the amount of the ERC-20 that will be delegated to the borrower (i.e 500 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

AaveCollateralWithdrawCondition

Implementation of the Collateral Withdraw Condition This condition allows to credit delegator withdraw the collateral and fees after the agreement expiration

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _collateralAsset) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the asset used as collateral (i.e DAI)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _collateralAsset) external payable returns (enum ConditionStoreLibrary.ConditionState)

It allows the borrower to repay the loan

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the asset used as collateral (i.e DAI)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

AaveCreditVault

lendingPool

contract ILendingPool lendingPool

dataProvider

contract IProtocolDataProvider dataProvider

weth

contract IWETHGateway weth

addressProvider

contract ILendingPoolAddressesProvider addressProvider

priceOracle

contract IPriceOracleGetter priceOracle

borrowedAsset

address borrowedAsset

borrowedAmount

uint256 borrowedAmount

nvmFee

uint256 nvmFee

agreementFee

uint256 agreementFee

FEE_BASE

uint256 FEE_BASE

treasuryAddress

address treasuryAddress

borrower

address borrower

lender

address lender

repayConditionId

bytes32 repayConditionId

nftId

uint256 nftId

nftAddress

address nftAddress

BORROWER_ROLE

bytes32 BORROWER_ROLE

LENDER_ROLE

bytes32 LENDER_ROLE

CONDITION_ROLE

bytes32 CONDITION_ROLE

initialize

function initialize(address _lendingPool, address _dataProvider, address _weth, uint256 _nvmFee, uint256 _agreementFee, address _treasuryAddress, address _borrower, address _lender, address[] _conditions) public

Vault constructor, creates a unique vault for each agreement

NameTypeDescription
_lendingPooladdressAave lending pool address
_dataProvideraddressAave data provider address
_wethaddressWETH address
_nvmFeeuint256Nevermined fee that will apply to this agreeement
_agreementFeeuint256Agreement fee that lender will receive on agreement maturity
_treasuryAddressaddressAddress of nevermined contract to store fees
_borroweraddress
_lenderaddress
_conditionsaddress[]

isLender

function isLender(address _address) public view returns (bool)

isBorrower

function isBorrower(address _address) public view returns (bool)

deposit

function deposit(address _collateralAsset, uint256 _amount) public payable

Deposit function. Receives the funds from the delegator and deposits the funds in the Aave contracts

NameTypeDescription
_collateralAssetaddresscollateral asset that will be deposit on Aave
_amountuint256Amount of collateral to deposit

approveBorrower

function approveBorrower(address _borrower, uint256 _amount, address _asset, uint256 _interestRateMode) public

Appproves delegatee to borrow funds from Aave on behalf of delegator

NameTypeDescription
_borroweraddressdelegatee that will borrow the funds
_amountuint256Amount of funds to delegate
_assetaddressAsset to delegate the borrow
_interestRateModeuint256interest rate type stable 1, variable 2

delegatedAmount

function delegatedAmount(address _borrower, address _asset, uint256 _interestRateMode) public view returns (uint256)

Return the actual delegated amount for the borrower in the specific asset

NameTypeDescription
_borroweraddressThe borrower of the funds (i.e. delgatee)
_assetaddressThe asset they are allowed to borrow
_interestRateModeuint256interest rate type stable 1, variable 2

borrow

function borrow(address _assetToBorrow, uint256 _amount, address _delgatee, uint256 _interestRateMode) public

Borrower can call this function to borrow the delegated funds

NameTypeDescription
_assetToBorrowaddressThe asset they are allowed to borrow
_amountuint256Amount to borrow
_delgateeaddressAddress where the funds will be transfered
_interestRateModeuint256interest rate type stable 1, variable 2

repay

function repay(address _asset, uint256 _interestRateMode, bytes32 _repayConditionId) public

Repay an uncollaterised loan

NameTypeDescription
_assetaddressThe asset to be repaid
_interestRateModeuint256interest rate type stable 1, variable 2
_repayConditionIdbytes32identifier of the condition id working as lock for other vault methods

setRepayConditionId

function setRepayConditionId(bytes32 _repayConditionId) public

getBorrowedAmount

function getBorrowedAmount() public view returns (uint256)

Returns the borrowed amount from the delegatee on this agreement

getAssetPrice

function getAssetPrice(address _asset) public view returns (uint256)

Returns the priceof the asset in the Aave oracles

NameTypeDescription
_assetaddressThe asset to get the actual price

getCreditAssetDebt

function getCreditAssetDebt() public view returns (uint256)

Returns the total debt of the credit in the Aave protocol expressed in token units

getActualCreditDebt

function getActualCreditDebt() public view returns (uint256)

Returns the total debt of the credit in the Aave protocol expressed in ETH units

getTotalActualDebt

function getTotalActualDebt() public view returns (uint256)

Returns the total actual debt of the agreement credit + fees in token units

withdrawCollateral

function withdrawCollateral(address _asset, address _delegator) public

Withdraw all of a collateral as the underlying asset, if no outstanding loans delegated

NameTypeDescription
_assetaddressThe underlying asset to withdraw
_delegatoraddressDelegator address that deposited the collateral

transferNFT

function transferNFT(uint256 _tokenId, address _receiver) public

Transfer a NFT (ERC-721) locked into the vault to a receiver address

NameTypeDescription
_tokenIduint256the token id
_receiveraddressthe receiver adddress

_transferERC20

function _transferERC20(address _collateralAsset, uint256 _amount) internal

Transfers the ERC20 token deposited to the Aave contracts

NameTypeDescription
_collateralAssetaddresscollateral asset that will be deposit on Aave
_amountuint256Amount of collateral to deposit

onERC721Received

function onERC721Received(address, address, uint256 _tokenId, bytes) public virtual returns (bytes4)

Handle the receipt of an NFT

_The ERC721 smart contract calls this function on the recipient after a {IERC721-safeTransferFrom}. This function MUST return the function selector, otherwise the caller will revert the transaction.

Note: the ERC721 contract address is always the message sender. (param not used): operator The address which called safeTransferFrom function (param not used): from The address which previously owned the token_

NameTypeDescription
address
address
_tokenIduint256The NFT identifier which is being transferred (param not used): data Additional data with no specified format
bytes
NameTypeDescription
[0]bytes4bytes4 bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))

AaveRepayCondition

Implementation of the Aave Repay Condition This condition allows to a borrower to repay a credit as part of a credit template

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _assetToRepay, uint256 _amountToRepay, uint256 _interestRateMode) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToRepayaddressthe address of the asset to repay (i.e DAI)
_amountToRepayuint256Amount to repay
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _assetToRepay, uint256 _amountToRepay, uint256 _interestRateMode) external returns (enum ConditionStoreLibrary.ConditionState)

It allows the borrower to repay the loan

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToRepayaddressthe address of the asset to repay (i.e DAI)
_amountToRepayuint256Amount to repay
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

EscrowPaymentCondition

_Implementation of the Escrow Payment Condition

 The Escrow payment is reward condition in which only 
can release reward if lock and release conditions
are fulfilled._

CONDITION_TYPE

bytes32 CONDITION_TYPE

USED_PAYMENT_ID

bytes32 USED_PAYMENT_ID

Fulfilled

event Fulfilled(bytes32 _agreementId, address _tokenAddress, address[] _receivers, bytes32 _conditionId, uint256[] _amounts)

Received

event Received(address _from, uint256 _value)

receive

receive() external payable

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValuesMulti

function hashValuesMulti(bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32asset decentralized identifier
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

encodeParams

function encodeParams(bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes)

hashValues

function hashValues(bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32 _releaseCondition) public pure returns (bytes32)

hashValuesLockPayment

function hashValuesLockPayment(bytes32 _did, address _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public pure returns (bytes32)

hashValuesLockPayment generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_rewardAddressaddressthe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfillMulti

function fulfillMulti(bytes32 _agreementId, bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill escrow reward condition

fulfill method checks whether the lock and release conditions are fulfilled in order to release/refund the reward to receiver/sender respectively.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

Args

struct Args {
bytes32 _agreementId;
bytes32 _did;
uint256[] _amounts;
address[] _receivers;
address _returnAddress;
address _lockPaymentAddress;
address _tokenAddress;
bytes32 _lockCondition;
bytes32[] _releaseConditions;
}

fulfillKludge

function fulfillKludge(struct EscrowPaymentCondition.Args a) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32 _releaseCondition) external returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfillERC20

function _transferAndFulfillERC20(bytes32 _id, address _tokenAddress, address[] _receivers, uint256[] _amounts) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ERC20 tokens and fulfill the condition

NameTypeDescription
_idbytes32condition identifier
_tokenAddressaddressthe ERC20 contract address to use during the payment
_receiversaddress[]receiver's address
_amountsuint256[]token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

_transferAndFulfillETH

function _transferAndFulfillETH(bytes32 _id, address[] _receivers, uint256[] _amounts) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ETH and fulfill the condition

NameTypeDescription
_idbytes32condition identifier
_receiversaddress[]receiver's address
_amountsuint256[]token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

INFTEscrow

Common interface for ERC-721 and ERC-1155

Fulfilled

event Fulfilled(bytes32 _agreementId, address _tokenAddress, bytes32 _did, address _receivers, bytes32 _conditionId, uint256 _amounts)

NFT721EscrowPaymentCondition

_Implementation of the Escrow Payment Condition

 The Escrow payment is reward condition in which only 
can release reward if lock and release conditions
are fulfilled._

CONDITION_TYPE

bytes32 CONDITION_TYPE

Received

event Received(address _from, uint256 _value)

receive

receive() external payable

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, uint256 _amounts, address _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32asset decentralized identifier
_amountsuint256token amounts to be locked/released
_receiversaddressreceiver's addresses
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesLockPayment

function hashValuesLockPayment(bytes32 _did, address _lockAddress, address _nftContractAddress, uint256 _amount, address _receiver) public pure returns (bytes32)

hashValuesLockPayment generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_lockAddressaddressthe contract address where the reward is locked
_nftContractAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, uint256 _amount, address _receiver, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill escrow reward condition

fulfill method checks whether the lock and release conditions are fulfilled in order to release/refund the reward to receiver/sender respectively.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

Args

struct Args {
bytes32 _agreementId;
bytes32 _did;
uint256 _amount;
address _receiver;
address _returnAddress;
address _lockPaymentAddress;
address _tokenAddress;
bytes32 _lockCondition;
bytes32[] _releaseConditions;
}

fulfillKludge

function fulfillKludge(struct NFT721EscrowPaymentCondition.Args a) internal returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfillNFT

function _transferAndFulfillNFT(bytes32 _agreementId, bytes32 _id, bytes32 _did, address _tokenAddress, address _receiver, uint256 _amount) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ERC20 tokens and fulfill the condition

NameTypeDescription
_agreementIdbytes32
_idbytes32condition identifier
_didbytes32
_tokenAddressaddressthe ERC20 contract address to use during the payment
_receiveraddressreceiver's address
_amountuint256token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

onERC721Received

function onERC721Received(address, address, uint256, bytes) public virtual returns (bytes4)

NFTEscrowPaymentCondition

_Implementation of the Escrow Payment Condition

 The Escrow payment is reward condition in which only 
can release reward if lock and release conditions
are fulfilled._

CONDITION_TYPE

bytes32 CONDITION_TYPE

LOCK_CONDITION_TYPE

bytes32 LOCK_CONDITION_TYPE

Received

event Received(address _from, uint256 _value)

receive

receive() external payable

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, uint256 _amounts, address _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32asset decentralized identifier
_amountsuint256token amounts to be locked/released
_receiversaddressreceiver's addresses
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesLockPayment

function hashValuesLockPayment(bytes32 _did, address _lockAddress, address _nftContractAddress, uint256 _amount, address _receiver) public pure returns (bytes32)

hashValuesLockPayment generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_lockAddressaddressthe contract address where the reward is locked
_nftContractAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, uint256 _amount, address _receiver, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill escrow reward condition

fulfill method checks whether the lock and release conditions are fulfilled in order to release/refund the reward to receiver/sender respectively.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

Args

struct Args {
bytes32 _agreementId;
bytes32 _did;
uint256 _amount;
address _receiver;
address _returnAddress;
address _lockPaymentAddress;
address _tokenAddress;
bytes32 _lockCondition;
bytes32[] _releaseConditions;
}

fulfillKludge

function fulfillKludge(struct NFTEscrowPaymentCondition.Args a) internal returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfillNFT

function _transferAndFulfillNFT(bytes32 _agreementId, bytes32 _id, bytes32 _did, address _tokenAddress, address _receiver, uint256 _amount) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ERC20 tokens and fulfill the condition

NameTypeDescription
_agreementIdbytes32
_idbytes32condition identifier
_didbytes32
_tokenAddressaddressthe ERC20 contract address to use during the payment
_receiveraddressreceiver's address
_amountuint256token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

ERC1155_ACCEPTED

bytes4 ERC1155_ACCEPTED

ERC1155_BATCH_ACCEPTED

bytes4 ERC1155_BATCH_ACCEPTED

onERC1155Received

function onERC1155Received(address, address, uint256, uint256, bytes) external pure returns (bytes4)

onERC1155BatchReceived

function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) external pure returns (bytes4)

supportsInterface

function supportsInterface(bytes4 interfaceId) external pure returns (bool)

_Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created.

This function call must use less than 30 000 gas._

Reward

_Implementation of the Reward.

 Generic reward condition_

INVMConfig

GOVERNOR_ROLE

bytes32 GOVERNOR_ROLE

NeverminedConfigChange

event NeverminedConfigChange(address _whoChanged, bytes32 _parameter)

Event that is emitted when a parameter is changed

NameTypeDescription
_whoChangedaddressthe address of the governor changing the parameter
_parameterbytes32the hash of the name of the parameter changed

initialize

function initialize(address _owner, address _governor) external virtual

Used to initialize the contract during delegator constructor

NameTypeDescription
_owneraddressThe owner of the contract
_governoraddressThe address to be granted with the GOVERNOR_ROLE

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver) external virtual

The governor can update the Nevermined Marketplace fees

NameTypeDescription
_marketplaceFeeuint256new marketplace fee
_feeReceiveraddressThe address receiving the fee

isGovernor

function isGovernor(address _address) external view virtual returns (bool)

Indicates if an address is a having the GOVERNOR role

NameTypeDescription
_addressaddressThe address to validate
NameTypeDescription
[0]booltrue if is a governor

getMarketplaceFee

function getMarketplaceFee() external view virtual returns (uint256)

Returns the marketplace fee

NameTypeDescription
[0]uint256the marketplace fee

getFeeReceiver

function getFeeReceiver() external view virtual returns (address)

Returns the receiver address of the marketplace fee

NameTypeDescription
[0]addressthe receiver address

NeverminedConfig

marketplaceFee

uint256 marketplaceFee

feeReceiver

address feeReceiver

initialize

function initialize(address _owner, address _governor) public

Used to initialize the contract during delegator constructor

NameTypeDescription
_owneraddressThe owner of the contract
_governoraddressThe address to be granted with the GOVERNOR_ROLE

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver) external virtual

The governor can update the Nevermined Marketplace fees

NameTypeDescription
_marketplaceFeeuint256new marketplace fee
_feeReceiveraddressThe address receiving the fee

setGovernor

function setGovernor(address _address) external

isGovernor

function isGovernor(address _address) external view returns (bool)

Indicates if an address is a having the GOVERNOR role

NameTypeDescription
_addressaddressThe address to validate
NameTypeDescription
[0]booltrue if is a governor

getMarketplaceFee

function getMarketplaceFee() external view returns (uint256)

Returns the marketplace fee

NameTypeDescription
[0]uint256the marketplace fee

getFeeReceiver

function getFeeReceiver() external view returns (address)

Returns the receiver address of the marketplace fee

NameTypeDescription
[0]addressthe receiver address

onlyGovernor

modifier onlyGovernor(address _address)

IERC20

totalSupply

function totalSupply() external view returns (uint256)

Returns the amount of tokens in existence.

balanceOf

function balanceOf(address account) external view returns (uint256)

Returns the amount of tokens owned by account.

transfer

function transfer(address recipient, uint256 amount) external returns (bool)

_Moves amount tokens from the caller's account to recipient.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event._

allowance

function allowance(address owner, address spender) external view returns (uint256)

_Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through {transferFrom}. This is zero by default.

This value changes when {approve} or {transferFrom} are called._

approve

function approve(address spender, uint256 amount) external returns (bool)

_Sets amount as the allowance of spender over the caller's tokens.

Returns a boolean value indicating whether the operation succeeded.

IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

Emits an {Approval} event._

transferFrom

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool)

_Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event._

Transfer

event Transfer(address from, address to, uint256 value)

_Emitted when value tokens are moved from one account (from) to another (to).

Note that value may be zero._

Approval

event Approval(address owner, address spender, uint256 value)

Emitted when the allowance of a spender for an owner is set by a call to {approve}. value is the new allowance.

IPriceOracleGetter

Interface for the Aave price oracle.

getAssetPrice

function getAssetPrice(address asset) external view returns (uint256)

returns the asset price in ETH

NameTypeDescription
assetaddressthe address of the asset
NameTypeDescription
[0]uint256the ETH price of the asset

IProtocolDataProvider

TokenData

struct TokenData {
string symbol;
address tokenAddress;
}

ADDRESSES_PROVIDER

function ADDRESSES_PROVIDER() external view returns (contract ILendingPoolAddressesProvider)

getAllReservesTokens

function getAllReservesTokens() external view returns (struct IProtocolDataProvider.TokenData[])

getAllATokens

function getAllATokens() external view returns (struct IProtocolDataProvider.TokenData[])

getReserveConfigurationData

function getReserveConfigurationData(address asset) external view returns (uint256 decimals, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive, bool isFrozen)

getReserveData

function getReserveData(address asset) external view returns (uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 liquidityRate, uint256 variableBorrowRate, uint256 stableBorrowRate, uint256 averageStableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex, uint40 lastUpdateTimestamp)

getUserReserveData

function getUserReserveData(address asset, address user) external view returns (uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled)

getReserveTokensAddresses

function getReserveTokensAddresses(address asset) external view returns (address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress)

ILendingPoolAddressesProvider

MarketIdSet

event MarketIdSet(string newMarketId)

LendingPoolUpdated

event LendingPoolUpdated(address newAddress)

ConfigurationAdminUpdated

event ConfigurationAdminUpdated(address newAddress)

EmergencyAdminUpdated

event EmergencyAdminUpdated(address newAddress)

LendingPoolConfiguratorUpdated

event LendingPoolConfiguratorUpdated(address newAddress)

LendingPoolCollateralManagerUpdated

event LendingPoolCollateralManagerUpdated(address newAddress)

PriceOracleUpdated

event PriceOracleUpdated(address newAddress)

LendingRateOracleUpdated

event LendingRateOracleUpdated(address newAddress)

ProxyCreated

event ProxyCreated(bytes32 id, address newAddress)

AddressSet

event AddressSet(bytes32 id, address newAddress, bool hasProxy)

getMarketId

function getMarketId() external view returns (string)

setMarketId

function setMarketId(string marketId) external

setAddress

function setAddress(bytes32 id, address newAddress) external

setAddressAsProxy

function setAddressAsProxy(bytes32 id, address impl) external

getAddress

function getAddress(bytes32 id) external view returns (address)

getLendingPool

function getLendingPool() external view returns (address)

setLendingPoolImpl

function setLendingPoolImpl(address pool) external

getLendingPoolConfigurator

function getLendingPoolConfigurator() external view returns (address)

setLendingPoolConfiguratorImpl

function setLendingPoolConfiguratorImpl(address configurator) external

getLendingPoolCollateralManager

function getLendingPoolCollateralManager() external view returns (address)

setLendingPoolCollateralManager

function setLendingPoolCollateralManager(address manager) external

getPoolAdmin

function getPoolAdmin() external view returns (address)

setPoolAdmin

function setPoolAdmin(address admin) external

getEmergencyAdmin

function getEmergencyAdmin() external view returns (address)

setEmergencyAdmin

function setEmergencyAdmin(address admin) external

getPriceOracle

function getPriceOracle() external view returns (address)

setPriceOracle

function setPriceOracle(address priceOracle) external

getLendingRateOracle

function getLendingRateOracle() external view returns (address)

setLendingRateOracle

function setLendingRateOracle(address lendingRateOracle) external

ILendingPool

Deposit

event Deposit(address reserve, address user, address onBehalfOf, uint256 amount, uint16 referral)

Emitted on deposit()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address initiating the deposit
onBehalfOfaddressThe beneficiary of the deposit, receiving the aTokens
amountuint256The amount deposited
referraluint16The referral code used

Withdraw

event Withdraw(address reserve, address user, address to, uint256 amount)

Emitted on withdraw()

NameTypeDescription
reserveaddressThe address of the underlyng asset being withdrawn
useraddressThe address initiating the withdrawal, owner of aTokens
toaddressAddress that will receive the underlying
amountuint256The amount to be withdrawn

Borrow

event Borrow(address reserve, address user, address onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 referral)

Emitted on borrow() and flashLoan() when debt needs to be opened

NameTypeDescription
reserveaddressThe address of the underlying asset being borrowed
useraddressThe address of the user initiating the borrow(), receiving the funds on borrow() or just initiator of the transaction on flashLoan()
onBehalfOfaddressThe address that will be getting the debt
amountuint256The amount borrowed out
borrowRateModeuint256The rate mode: 1 for Stable, 2 for Variable
borrowRateuint256The numeric rate at which the user has borrowed
referraluint16The referral code used

Repay

event Repay(address reserve, address user, address repayer, uint256 amount)

Emitted on repay()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe beneficiary of the repayment, getting his debt reduced
repayeraddressThe address of the user initiating the repay(), providing the funds
amountuint256The amount repaid

Swap

event Swap(address reserve, address user, uint256 rateMode)

Emitted on swapBorrowRateMode()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user swapping his rate mode
rateModeuint256The rate mode that the user wants to swap to

ReserveUsedAsCollateralEnabled

event ReserveUsedAsCollateralEnabled(address reserve, address user)

Emitted on setUserUseReserveAsCollateral()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user enabling the usage as collateral

ReserveUsedAsCollateralDisabled

event ReserveUsedAsCollateralDisabled(address reserve, address user)

Emitted on setUserUseReserveAsCollateral()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user enabling the usage as collateral

RebalanceStableBorrowRate

event RebalanceStableBorrowRate(address reserve, address user)

Emitted on rebalanceStableBorrowRate()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user for which the rebalance has been executed

FlashLoan

event FlashLoan(address target, address initiator, address asset, uint256 amount, uint256 premium, uint16 referralCode)

Emitted on flashLoan()

NameTypeDescription
targetaddressThe address of the flash loan receiver contract
initiatoraddressThe address initiating the flash loan
assetaddressThe address of the asset being flash borrowed
amountuint256The amount flash borrowed
premiumuint256The fee flash borrowed
referralCodeuint16The referral code used

Paused

event Paused()

Emitted when the pause is triggered.

Unpaused

event Unpaused()

Emitted when the pause is lifted.

LiquidationCall

event LiquidationCall(address collateralAsset, address debtAsset, address user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken)

Emitted when a borrower is liquidated. This event is emitted by the LendingPool via LendingPoolCollateral manager using a DELEGATECALL This allows to have the events in the generated ABI for LendingPool.

NameTypeDescription
collateralAssetaddressThe address of the underlying asset used as collateral, to receive as result of the liquidation
debtAssetaddressThe address of the underlying borrowed asset to be repaid with the liquidation
useraddressThe address of the borrower getting liquidated
debtToCoveruint256The debt amount of borrowed asset the liquidator wants to cover
liquidatedCollateralAmountuint256The amount of collateral received by the liiquidator
liquidatoraddressThe address of the liquidator
receiveATokenbooltrue if the liquidators wants to receive the collateral aTokens, false if he wants to receive the underlying collateral asset directly

ReserveDataUpdated

event ReserveDataUpdated(address reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex)

Emitted when the state of a reserve is updated. NOTE: This event is actually declared in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it gets added to the LendingPool ABI

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
liquidityRateuint256The new liquidity rate
stableBorrowRateuint256The new stable borrow rate
variableBorrowRateuint256The new variable borrow rate
liquidityIndexuint256The new liquidity index
variableBorrowIndexuint256The new variable borrow index

deposit

function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external

_Deposits an amount of underlying asset into the reserve, receiving in return overlying aTokens.

  • E.g. User deposits 100 USDC and gets in return 100 aUSDC_
NameTypeDescription
assetaddressThe address of the underlying asset to deposit
amountuint256The amount to be deposited
onBehalfOfaddressThe address that will receive the aTokens, same as msg.sender if the user wants to receive them on his own wallet, or a different address if the beneficiary of aTokens is a different wallet
referralCodeuint16Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man

withdraw

function withdraw(address asset, uint256 amount, address to) external returns (uint256)

Withdraws an amount of underlying asset from the reserve, burning the equivalent aTokens owned E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC

NameTypeDescription
assetaddressThe address of the underlying asset to withdraw
amountuint256The underlying amount to be withdrawn - Send the value type(uint256).max in order to withdraw the whole aToken balance
toaddressAddress that will receive the underlying, same as msg.sender if the user wants to receive it on his own wallet, or a different address if the beneficiary is a different wallet
NameTypeDescription
[0]uint256The final amount withdrawn

borrow

function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf) external

_Allows users to borrow a specific amount of the reserve underlying asset, provided that the borrower already deposited enough collateral, or he was given enough allowance by a credit delegator on the corresponding debt token (StableDebtToken or VariableDebtToken)

  • E.g. User borrows 100 USDC passing as onBehalfOf his own address, receiving the 100 USDC in his wallet and 100 stable/variable debt tokens, depending on the interestRateMode_
NameTypeDescription
assetaddressThe address of the underlying asset to borrow
amountuint256The amount to be borrowed
interestRateModeuint256The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable
referralCodeuint16Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man
onBehalfOfaddressAddress of the user who will receive the debt. Should be the address of the borrower itself calling the function if he wants to borrow against his own collateral, or the address of the credit delegator if he has been given credit delegation allowance

repay

function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf) external returns (uint256)

Repays a borrowed amount on a specific reserve, burning the equivalent debt tokens owned

  • E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the onBehalfOf address
NameTypeDescription
assetaddressThe address of the borrowed underlying asset previously borrowed
amountuint256The amount to repay - Send the value type(uint256).max in order to repay the whole debt for asset on the specific debtMode
rateModeuint256The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable
onBehalfOfaddressAddress of the user who will get his debt reduced/removed. Should be the address of the user calling the function if he wants to reduce/remove his own debt, or the address of any other other borrower whose debt should be removed
NameTypeDescription
[0]uint256The final amount repaid

swapBorrowRateMode

function swapBorrowRateMode(address asset, uint256 rateMode) external

Allows a borrower to swap his debt between stable and variable mode, or viceversa

NameTypeDescription
assetaddressThe address of the underlying asset borrowed
rateModeuint256The rate mode that the user wants to swap to

rebalanceStableBorrowRate

function rebalanceStableBorrowRate(address asset, address user) external

_Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.

  • Users can be rebalanced if the following conditions are satisfied:
    1. Usage ratio is above 95%
    2. the current deposit APY is below REBALANCEUP_THRESHOLD * maxVariableBorrowRate, which means that too much has been borrowed at a stable rate and depositors are not earning enough
NameTypeDescription
assetaddressThe address of the underlying asset borrowed
useraddressThe address of the user to be rebalanced

setUserUseReserveAsCollateral

function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external

Allows depositors to enable/disable a specific deposited asset as collateral

NameTypeDescription
assetaddressThe address of the underlying asset deposited
useAsCollateralbooltrue if the user wants to use the deposit as collateral, false otherwise

liquidationCall

function liquidationCall(address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken) external

_Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1

  • The caller (liquidator) covers debtToCover amount of debt of the user getting liquidated, and receives a proportionally amount of the collateralAsset plus a bonus to cover market risk_
NameTypeDescription
collateralAssetaddressThe address of the underlying asset used as collateral, to receive as result of the liquidation
debtAssetaddressThe address of the underlying borrowed asset to be repaid with the liquidation
useraddressThe address of the borrower getting liquidated
debtToCoveruint256The debt amount of borrowed asset the liquidator wants to cover
receiveATokenbooltrue if the liquidators wants to receive the collateral aTokens, false if he wants to receive the underlying collateral asset directly

flashLoan

function flashLoan(address receiverAddress, address[] assets, uint256[] amounts, uint256[] modes, address onBehalfOf, bytes params, uint16 referralCode) external

Allows smartcontracts to access the liquidity of the pool within one transaction, as long as the amount taken plus a fee is returned. IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. For further details please visit https://developers.aave.com

NameTypeDescription
receiverAddressaddressThe address of the contract receiving the funds, implementing the IFlashLoanReceiver interface
assetsaddress[]The addresses of the assets being flash-borrowed
amountsuint256[]The amounts amounts being flash-borrowed
modesuint256[]Types of the debt to open if the flash loan is not returned: 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the onBehalfOf address 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the onBehalfOf address
onBehalfOfaddressThe address that will receive the debt in the case of using on modes 1 or 2
paramsbytesVariadic packed params to pass to the receiver as extra information
referralCodeuint16Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man

getUserAccountData

function getUserAccountData(address user) external view returns (uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)

Returns the user account data across all the reserves

NameTypeDescription
useraddressThe address of the user
NameTypeDescription
totalCollateralETHuint256the total collateral in ETH of the user
totalDebtETHuint256the total debt in ETH of the user
availableBorrowsETHuint256the borrowing power left of the user
currentLiquidationThresholduint256the liquidation threshold of the user
ltvuint256the loan to value of the user
healthFactoruint256the current health factor of the user

initReserve

function initReserve(address reserve, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress) external

setReserveInterestRateStrategyAddress

function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external

setConfiguration

function setConfiguration(address reserve, uint256 configuration) external

getConfiguration

function getConfiguration(address asset) external view returns (struct DataTypes.ReserveConfigurationMap)

Returns the configuration of the reserve

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]struct DataTypes.ReserveConfigurationMapThe configuration of the reserve

getUserConfiguration

function getUserConfiguration(address user) external view returns (struct DataTypes.UserConfigurationMap)

Returns the configuration of the user across all the reserves

NameTypeDescription
useraddressThe user address
NameTypeDescription
[0]struct DataTypes.UserConfigurationMapThe configuration of the user

getReserveNormalizedIncome

function getReserveNormalizedIncome(address asset) external view returns (uint256)

Returns the normalized income normalized income of the reserve

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]uint256The reserve's normalized income

getReserveNormalizedVariableDebt

function getReserveNormalizedVariableDebt(address asset) external view returns (uint256)

Returns the normalized variable debt per unit of asset

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]uint256The reserve normalized variable debt

getReserveData

function getReserveData(address asset) external view returns (struct DataTypes.ReserveData)

Returns the state and configuration of the reserve

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]struct DataTypes.ReserveDataThe state of the reserve

finalizeTransfer

function finalizeTransfer(address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore) external

getReservesList

function getReservesList() external view returns (address[])

getAddressesProvider

function getAddressesProvider() external view returns (contract ILendingPoolAddressesProvider)

setPause

function setPause(bool val) external

paused

function paused() external view returns (bool)

IStableDebtToken

Mint

event Mint(address user, address onBehalfOf, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 newRate, uint256 avgStableRate, uint256 newTotalSupply)

Emitted when new stable debt is minted

NameTypeDescription
useraddressThe address of the user who triggered the minting
onBehalfOfaddressThe recipient of stable debt tokens
amountuint256The amount minted
currentBalanceuint256The current balance of the user
balanceIncreaseuint256The increase in balance since the last action of the user
newRateuint256The rate of the debt after the minting
avgStableRateuint256The new average stable rate after the minting
newTotalSupplyuint256The new total supply of the stable debt token after the action

Burn

event Burn(address user, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 avgStableRate, uint256 newTotalSupply)

Emitted when new stable debt is burned

NameTypeDescription
useraddressThe address of the user
amountuint256The amount being burned
currentBalanceuint256The current balance of the user
balanceIncreaseuint256The the increase in balance since the last action of the user
avgStableRateuint256The new average stable rate after the burning
newTotalSupplyuint256The new total supply of the stable debt token after the action

approveDelegation

function approveDelegation(address delegatee, uint256 amount) external

delegates borrowing power to a user on the specific debt token

NameTypeDescription
delegateeaddressthe address receiving the delegated borrowing power
amountuint256the maximum amount being delegated. Delegation will still respect the liquidation constraints (even if delegated, a delegatee cannot force a delegator HF to go below 1)

borrowAllowance

function borrowAllowance(address fromUser, address toUser) external view returns (uint256)

returns the borrow allowance of the user

NameTypeDescription
fromUseraddressThe user to giving allowance
toUseraddressThe user to give allowance to
NameTypeDescription
[0]uint256the current allowance of toUser

mint

function mint(address user, address onBehalfOf, uint256 amount, uint256 rate) external returns (bool)

_Mints debt token to the onBehalfOf address.

  • The resulting rate is the weighted average between the rate of the new debt and the rate of the previous debt_
NameTypeDescription
useraddressThe address receiving the borrowed underlying, being the delegatee in case of credit delegate, or same as onBehalfOf otherwise
onBehalfOfaddressThe address receiving the debt tokens
amountuint256The amount of debt tokens to mint
rateuint256The rate of the debt being minted

burn

function burn(address user, uint256 amount) external

_Burns debt of user

  • The resulting rate is the weighted average between the rate of the new debt and the rate of the previous debt_
NameTypeDescription
useraddressThe address of the user getting his debt burned
amountuint256The amount of debt tokens getting burned

getAverageStableRate

function getAverageStableRate() external view returns (uint256)

Returns the average rate of all the stable rate loans.

NameTypeDescription
[0]uint256The average stable rate

getUserStableRate

function getUserStableRate(address user) external view returns (uint256)

Returns the stable rate of the user debt

NameTypeDescription
[0]uint256The stable rate of the user

getUserLastUpdated

function getUserLastUpdated(address user) external view returns (uint40)

Returns the timestamp of the last update of the user

NameTypeDescription
[0]uint40The timestamp

getSupplyData

function getSupplyData() external view returns (uint256, uint256, uint256, uint40)

Returns the principal, the total supply and the average stable rate

getTotalSupplyLastUpdated

function getTotalSupplyLastUpdated() external view returns (uint40)

Returns the timestamp of the last update of the total supply

NameTypeDescription
[0]uint40The timestamp

getTotalSupplyAndAvgRate

function getTotalSupplyAndAvgRate() external view returns (uint256, uint256)

Returns the total supply and the average stable rate

principalBalanceOf

function principalBalanceOf(address user) external view returns (uint256)

Returns the principal debt balance of the user

NameTypeDescription
[0]uint256The debt balance of the user since the last burn/mint action

IDynamicPricing

DynamicPricingState

enum DynamicPricingState {
NotStarted,
Finished,
InProgress,
Aborted
}

getPricingType

function getPricingType() external view returns (bytes32)

getPrice

function getPrice(bytes32 did) external view returns (uint256)

getTokenAddress

function getTokenAddress(bytes32 did) external view returns (address)

getStatus

function getStatus(bytes32 did) external view returns (enum IDynamicPricing.DynamicPricingState, uint256, address)

canBePurchased

function canBePurchased(bytes32 did) external view returns (bool)

withdraw

function withdraw(bytes32 did, address withdrawAddress) external returns (bool)

IList

has

function has(bytes32 value) external view returns (bool)

has

function has(bytes32 value, bytes32 id) external view returns (bool)

IRoyaltyScheme

check

function check(bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) external view returns (bool)

check that royalties are correct

NameTypeDescription
_didbytes32compute royalties for this DID
_amountsuint256[]amounts in payment
_receiversaddress[]receivers of payments
_tokenAddressaddresspayment token. zero address means native token (ether)

ISecretStore

checkPermissions

function checkPermissions(address user, bytes32 documentKeyId) external view returns (bool permissionGranted)

checkPermissions is called by Parity secret store

ISecretStorePermission

grantPermission

function grantPermission(address user, bytes32 documentKeyId) external

grantPermission is called only by documentKeyId Owner or provider

renouncePermission

function renouncePermission(address user, bytes32 documentKeyId) external

renouncePermission is called only by documentKeyId Owner or provider

IWETHGateway

depositETH

function depositETH(address lendingPool, address onBehalfOf, uint16 referralCode) external payable

withdrawETH

function withdrawETH(address lendingPool, uint256 amount, address to) external

repayETH

function repayETH(address lendingPool, uint256 amount, uint256 rateMode, address onBehalfOf) external payable

borrowETH

function borrowETH(address lendingPool, uint256 amount, uint256 interesRateMode, uint16 referralCode) external

DataTypes

ReserveData

struct ReserveData {
struct DataTypes.ReserveConfigurationMap configuration;
uint128 liquidityIndex;
uint128 variableBorrowIndex;
uint128 currentLiquidityRate;
uint128 currentVariableBorrowRate;
uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
address interestRateStrategyAddress;
uint8 id;
}

ReserveConfigurationMap

struct ReserveConfigurationMap {
uint256 data;
}

UserConfigurationMap

struct UserConfigurationMap {
uint256 data;
}

InterestRateMode

enum InterestRateMode {
NONE,
STABLE,
VARIABLE
}

SafeMath

add

function add(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the addition of two unsigned integers, reverting on overflow.

Counterpart to Solidity's + operator.

Requirements:

  • Addition cannot overflow._

sub

function sub(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative).

Counterpart to Solidity's - operator.

Requirements:

  • Subtraction cannot overflow._

sub

function sub(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)

_Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative).

Counterpart to Solidity's - operator.

Requirements:

  • Subtraction cannot overflow._

mul

function mul(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the multiplication of two unsigned integers, reverting on overflow.

Counterpart to Solidity's * operator.

Requirements:

  • Multiplication cannot overflow._

div

function div(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero.

Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

div

function div(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)

_Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero.

Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

mod

function mod(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero.

Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

mod

function mod(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)

_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero.

Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

Address

isContract

function isContract(address account) internal view returns (bool)

_Returns true if account is a contract.

[IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract.

Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====_

sendValue

function sendValue(address payable recipient, uint256 amount) internal

_Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors.

https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. {sendValue} removes this limitation.

https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].

IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]._

SafeERC20

Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a using SafeERC20 for IERC20; statement to your contract, which allows you to call the safe operations as token.safeTransfer(...), etc.

safeTransfer

function safeTransfer(contract IERC20 token, address to, uint256 value) internal

safeTransferFrom

function safeTransferFrom(contract IERC20 token, address from, address to, uint256 value) internal

safeApprove

function safeApprove(contract IERC20 token, address spender, uint256 value) internal

callOptionalReturn

function callOptionalReturn(contract IERC20 token, bytes data) private

CloneFactory

createClone

function createClone(address target) internal returns (address result)

isClone

function isClone(address target, address query) internal view returns (bool result)

EpochLibrary

Implementation of Epoch Library. For an arbitrary Epoch, this library manages the life cycle of an Epoch. Usually this library is used for handling the time window between conditions in an agreement.

Epoch

struct Epoch {
uint256 timeLock;
uint256 timeOut;
uint256 blockNumber;
}

EpochList

struct EpochList {
mapping(bytes32 => struct EpochLibrary.Epoch) epochs;
bytes32[] epochIds;
}

create

function create(struct EpochLibrary.EpochList _self, bytes32 _id, uint256 _timeLock, uint256 _timeOut) internal

create creates new Epoch

NameTypeDescription
_selfstruct EpochLibrary.EpochListis the Epoch storage pointer
_idbytes32
_timeLockuint256value in block count (can not fulfill before)
_timeOutuint256value in block count (can not fulfill after)

isTimedOut

function isTimedOut(struct EpochLibrary.EpochList _self, bytes32 _id) external view returns (bool)

isTimedOut means you cannot fulfill after

NameTypeDescription
_selfstruct EpochLibrary.EpochListis the Epoch storage pointer
_idbytes32
NameTypeDescription
[0]booltrue if the current block number is gt timeOut

isTimeLocked

function isTimeLocked(struct EpochLibrary.EpochList _self, bytes32 _id) external view returns (bool)

isTimeLocked means you cannot fulfill before

NameTypeDescription
_selfstruct EpochLibrary.EpochListis the Epoch storage pointer
_idbytes32
NameTypeDescription
[0]booltrue if the current block number is gt timeLock

getEpochTimeOut

function getEpochTimeOut(struct EpochLibrary.Epoch _self) public view returns (uint256)

getEpochTimeOut

NameTypeDescription
_selfstruct EpochLibrary.Epochis the Epoch storage pointer

getEpochTimeLock

function getEpochTimeLock(struct EpochLibrary.Epoch _self) public view returns (uint256)

getEpochTimeLock

NameTypeDescription
_selfstruct EpochLibrary.Epochis the Epoch storage pointer

HashListLibrary

Implementation of the basic functionality of list of hash values. This library allows other contracts to build and maintain lists and also preserves the privacy of the data by accepting only hashed content (bytes32 based data type)

List

struct List {
address _owner;
bytes32[] values;
mapping(bytes32 => uint256) indices;
}

onlyListOwner

modifier onlyListOwner(struct HashListLibrary.List _self)

add

function add(struct HashListLibrary.List _self, bytes32 value) public returns (bool)

add index an element then add it to a list

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is a bytes32 value
NameTypeDescription
[0]booltrue if value is added successfully

add

function add(struct HashListLibrary.List _self, bytes32[] values) public returns (bool)

put an array of elements without indexing this meant to save gas in case of large arrays

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuesbytes32[]is an array of elements value
NameTypeDescription
[0]booltrue if values are added successfully

update

function update(struct HashListLibrary.List _self, bytes32 oldValue, bytes32 newValue) public returns (bool)

update the value with a new value and maintain indices

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
oldValuebytes32is an element value in a list
newValuebytes32new value
NameTypeDescription
[0]booltrue if value is updated successfully

remove

function remove(struct HashListLibrary.List _self, bytes32 value) public returns (bool)

remove value from a list, updates indices, and list size

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is an element value in a list
NameTypeDescription
[0]booltrue if value is removed successfully

get

function get(struct HashListLibrary.List _self, uint256 __index) public view returns (bytes32)

has value by index

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
__indexuint256is where is value is stored in the list
NameTypeDescription
[0]bytes32the value if exists

index

function index(struct HashListLibrary.List _self, uint256 from, uint256 to) public returns (bool)

index is used to map each element value to its index on the list

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
fromuint256index is where to 'from' indexing in the list
touint256index is where to stop indexing
NameTypeDescription
[0]booltrue if the sub list is indexed

setOwner

function setOwner(struct HashListLibrary.List _self, address _owner) public

setOwner set list owner param _owner owner address

indexOf

function indexOf(struct HashListLibrary.List _self, bytes32 value) public view returns (uint256)

indexOf gets the index of a value in a list

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is element value in list
NameTypeDescription
[0]uint256value index in list

isIndexed

function isIndexed(struct HashListLibrary.List _self) public view returns (bool)

isIndexed checks if the list is indexed

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]booltrue if the list is indexed

all

function all(struct HashListLibrary.List _self) public view returns (bytes32[])

all returns all list elements

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]bytes32[]all list elements

has

function has(struct HashListLibrary.List _self, bytes32 value) public view returns (bool)

size returns the list size

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is element value in list
NameTypeDescription
[0]booltrue if the value exists

size

function size(struct HashListLibrary.List _self) public view returns (uint256)

size gets the list size

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]uint256total length of the list

ownedBy

function ownedBy(struct HashListLibrary.List _self) public view returns (address)

ownedBy gets the list owner

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]addresslist owner

_index

function _index(struct HashListLibrary.List _self, uint256 from, uint256 to) private returns (bool)

_index assign index to the list elements

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
fromuint256is the starting index id
touint256is the ending index id

AbstractAuction

AUCTION_MANAGER_ROLE

bytes32 AUCTION_MANAGER_ROLE

NVM_AGREEMENT_ROLE

bytes32 NVM_AGREEMENT_ROLE

Auction

struct Auction {
bytes32 did;
enum IDynamicPricing.DynamicPricingState state;
address creator;
uint256 blockNumberCreated;
uint256 floor;
uint256 starts;
uint256 ends;
uint256 price;
address tokenAddress;
address whoCanClaim;
string hash;
}

auctions

mapping(bytes32 => struct AbstractAuction.Auction) auctions

auctionBids

mapping(bytes32 => mapping(address => uint256)) auctionBids

AuctionCreated

event AuctionCreated(bytes32 auctionId, bytes32 did, address creator, uint256 blockNumberCreated, uint256 floor, uint256 starts, uint256 ends, address tokenAddress)

AuctionChangedState

event AuctionChangedState(bytes32 auctionId, address who, enum IDynamicPricing.DynamicPricingState previousState, enum IDynamicPricing.DynamicPricingState newState)

AuctionBidReceived

event AuctionBidReceived(bytes32 auctionId, address bidder, address tokenAddress, uint256 amount)

AuctionWithdrawal

event AuctionWithdrawal(bytes32 auctionId, address receiver, address tokenAddress, uint256 amount)

receive

receive() external payable

abortAuction

function abortAuction(bytes32 _auctionId) external virtual

withdraw

function withdraw(bytes32 _auctionId, address _withdrawAddress) external virtual returns (bool)

getPricingType

function getPricingType() external pure virtual returns (bytes32)

getPrice

function getPrice(bytes32 _auctionId) external view returns (uint256)

getTokenAddress

function getTokenAddress(bytes32 _auctionId) external view returns (address)

getStatus

function getStatus(bytes32 _auctionId) external view returns (enum IDynamicPricing.DynamicPricingState state, uint256 price, address whoCanClaim)

canBePurchased

function canBePurchased(bytes32 _auctionId) external view virtual returns (bool)

addNVMAgreementRole

function addNVMAgreementRole(address account) public

onlyCreator

modifier onlyCreator(bytes32 _auctionId)

onlyCreatorOrAdmin

modifier onlyCreatorOrAdmin(bytes32 _auctionId)

onlyNotCreator

modifier onlyNotCreator(bytes32 _auctionId)

onlyAfterStart

modifier onlyAfterStart(bytes32 _auctionId)

onlyBeforeStarts

modifier onlyBeforeStarts(bytes32 _auctionId)

onlyBeforeEnd

modifier onlyBeforeEnd(bytes32 _auctionId)

onlyNotAbortedOrFinished

modifier onlyNotAbortedOrFinished(bytes32 _auctionId)

onlyAbortedOrFinished

modifier onlyAbortedOrFinished(bytes32 _auctionId)

onlyNotAborted

modifier onlyNotAborted(bytes32 _auctionId)

onlyFinishedOrAborted

modifier onlyFinishedOrAborted(bytes32 _auctionId)

DutchAuction

initialize

function initialize(address _owner) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address

create

function create(bytes32 _auctionId, bytes32 _did, uint256 _startPrice, uint256 _starts, uint256 _ends, address _tokenAddress, string _hash) external virtual

It creates a new Auction given some setup parameters

NameTypeDescription
_auctionIdbytes32unique auction identifier
_didbytes32reference to the asset part of the auction
_startPriceuint256start price (and max) for the auction
_startsuint256block number when the auction starts
_endsuint256block number of when the auction ends
_tokenAddressaddresstoken address to use for the auction. If address(0) means native token
_hashstringipfs hash referring to the auction metadata

placeNativeTokenBid

function placeNativeTokenBid(bytes32 _auctionId) external payable virtual

placeERC20Bid

function placeERC20Bid(bytes32 _auctionId, uint256 _bidAmount) external virtual

withdraw

function withdraw(bytes32 _auctionId, address _withdrawAddress) external virtual returns (bool)

getPricingType

function getPricingType() external pure returns (bytes32)

EnglishAuction

initialize

function initialize(address _owner) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address

create

function create(bytes32 _auctionId, bytes32 _did, uint256 _floor, uint256 _starts, uint256 _ends, address _tokenAddress, string _hash) external virtual

It creates a new Auction given some setup parameters

NameTypeDescription
_auctionIdbytes32unique auction identifier
_didbytes32reference to the asset part of the auction
_flooruint256floor price
_startsuint256block number when the auction starts
_endsuint256block number of when the auction ends
_tokenAddressaddresstoken address to use for the auction. If address(0) means native token
_hashstringipfs hash referring to the auction metadata

placeNativeTokenBid

function placeNativeTokenBid(bytes32 _auctionId) external payable virtual

placeERC20Bid

function placeERC20Bid(bytes32 _auctionId, uint256 _bidAmount) external virtual

getPricingType

function getPricingType() external pure returns (bytes32)

DIDFactory

Implementation of the DID Registry.

didRegisterList

struct DIDRegistryLibrary.DIDRegisterList didRegisterList

state storage for the DID registry

didPermissions

mapping(bytes32 => mapping(address => bool)) didPermissions

manager

address manager

onlyDIDOwner

modifier onlyDIDOwner(bytes32 _did)

onlyManager

modifier onlyManager()

onlyOwnerProviderOrDelegated

modifier onlyOwnerProviderOrDelegated(bytes32 _did)

onlyValidAttributes

modifier onlyValidAttributes(string _attributes)

nftIsInitialized

modifier nftIsInitialized(bytes32 _did)

nft721IsInitialized

modifier nft721IsInitialized(bytes32 _did)

DIDAttributeRegistered

event DIDAttributeRegistered(bytes32 _did, address _owner, bytes32 _checksum, string _value, address _lastUpdatedBy, uint256 _blockNumberUpdated)

DID Events

DIDProviderRemoved

event DIDProviderRemoved(bytes32 _did, address _provider, bool state)

DIDProviderAdded

event DIDProviderAdded(bytes32 _did, address _provider)

DIDOwnershipTransferred

event DIDOwnershipTransferred(bytes32 _did, address _previousOwner, address _newOwner)

DIDPermissionGranted

event DIDPermissionGranted(bytes32 _did, address _owner, address _grantee)

DIDPermissionRevoked

event DIDPermissionRevoked(bytes32 _did, address _owner, address _grantee)

DIDProvenanceDelegateRemoved

event DIDProvenanceDelegateRemoved(bytes32 _did, address _delegate, bool state)

DIDProvenanceDelegateAdded

event DIDProvenanceDelegateAdded(bytes32 _did, address _delegate)

setManager

function setManager(address _addr) external

Sets the manager role. Should be the TransferCondition contract address

registerAttribute

function registerAttribute(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url) public virtual

Register DID attributes.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]
_urlstringrefers to the attribute value, limited to 2048 bytes.

registerDID

function registerDID(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, bytes32 _activityId, string _attributes) public virtual

Register DID attributes.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID). The final DID will be calculated with the creator address using the hashDID function
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes

hashDID

function hashDID(bytes32 _didSeed, address _creator) public pure returns (bytes32)

It generates a DID using as seed a bytes32 and the address of the DID creator

NameTypeDescription
_didSeedbytes32refers to DID Seed used as base to generate the final DID
_creatoraddressaddress of the creator of the DID
NameTypeDescription
[0]bytes32the new DID created

areRoyaltiesValid

function areRoyaltiesValid(bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) public view returns (bool)

areRoyaltiesValid checks if for a given DID and rewards distribution, this allocate the
original creator royalties properly

NameTypeDescription
_didbytes32refers to decentralized identifier (a byte32 length ID)
_amountsuint256[]refers to the amounts to reward
_receiversaddress[]refers to the receivers of rewards
_tokenAddressaddress
NameTypeDescription
[0]booltrue if the rewards distribution respect the original creator royalties

wasGeneratedBy

function wasGeneratedBy(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) internal returns (bool)

used

function used(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, bytes _signatureUsing, string _attributes) public returns (bool success)

wasDerivedFrom

function wasDerivedFrom(bytes32 _provId, bytes32 _newEntityDid, bytes32 _usedEntityDid, address _agentId, bytes32 _activityId, string _attributes) public returns (bool success)

wasAssociatedWith

function wasAssociatedWith(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) public returns (bool success)

actedOnBehalf

function actedOnBehalf(bytes32 _provId, bytes32 _did, address _delegateAgentId, address _responsibleAgentId, bytes32 _activityId, bytes _signatureDelegate, string _attributes) public returns (bool success)

Implements the W3C PROV Delegation action Each party involved in this method (_delegateAgentId & _responsibleAgentId) must provide a valid signature. The content to sign is a representation of the footprint of the event (_did + _delegateAgentId + _responsibleAgentId + _activityId)

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity
_delegateAgentIdaddressrefers to address acting on behalf of the provenance record
_responsibleAgentIdaddressrefers to address responsible of the provenance record
_activityIdbytes32refers to activity
_signatureDelegatebytesrefers to the digital signature provided by the did delegate.
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

addDIDProvider

function addDIDProvider(bytes32 _did, address _provider) external

addDIDProvider add new DID provider.

it adds new DID provider to the providers list. A provider is any entity that can serve the registered asset

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_provideraddressprovider's address.

removeDIDProvider

function removeDIDProvider(bytes32 _did, address _provider) external

removeDIDProvider delete an existing DID provider.

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_provideraddressprovider's address.

addDIDProvenanceDelegate

function addDIDProvenanceDelegate(bytes32 _did, address _delegate) public

addDIDProvenanceDelegate add new DID provenance delegate.

it adds new DID provenance delegate to the delegates list. A delegate is any entity that interact with the provenance entries of one DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_delegateaddressdelegates's address.

removeDIDProvenanceDelegate

function removeDIDProvenanceDelegate(bytes32 _did, address _delegate) external

removeDIDProvenanceDelegate delete an existing DID delegate.

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_delegateaddressdelegate's address.

transferDIDOwnership

function transferDIDOwnership(bytes32 _did, address _newOwner) external

transferDIDOwnership transfer DID ownership

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_newOwneraddressnew owner address

transferDIDOwnershipManaged

function transferDIDOwnershipManaged(address _sender, bytes32 _did, address _newOwner) external

transferDIDOwnershipManaged transfer DID ownership

NameTypeDescription
_senderaddress
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_newOwneraddressnew owner address

_transferDIDOwnership

function _transferDIDOwnership(address _sender, bytes32 _did, address _newOwner) internal

grantPermission

function grantPermission(bytes32 _did, address _grantee) external

grantPermission grants access permission to grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

revokePermission

function revokePermission(bytes32 _did, address _grantee) external

revokePermission revokes access permission from grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

getPermission

function getPermission(bytes32 _did, address _grantee) external view returns (bool)

getPermission gets access permission of a grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress
NameTypeDescription
[0]booltrue if grantee has access permission to a DID

isDIDProvider

function isDIDProvider(bytes32 _did, address _provider) public view returns (bool)

isDIDProvider check whether a given DID provider exists

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_provideraddressprovider's address.

isDIDProviderOrOwner

function isDIDProviderOrOwner(bytes32 _did, address _provider) public view returns (bool)

getDIDRegister

function getDIDRegister(bytes32 _did) public view returns (address owner, bytes32 lastChecksum, string url, address lastUpdatedBy, uint256 blockNumberUpdated, address[] providers, uint256 nftSupply, uint256 mintCap, uint256 royalties)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
owneraddressthe did owner
lastChecksumbytes32last checksum
urlstringURL to the DID metadata
lastUpdatedByaddresswho was the last updating the DID
blockNumberUpdateduint256In which block was the DID updated
providersaddress[]the list of providers
nftSupplyuint256the supply of nfts
mintCapuint256the maximum number of nfts that can be minted
royaltiesuint256the royalties amount

getDIDSupply

function getDIDSupply(bytes32 _did) public view returns (uint256 nftSupply, uint256 mintCap)

getBlockNumberUpdated

function getBlockNumberUpdated(bytes32 _did) public view returns (uint256 blockNumberUpdated)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
blockNumberUpdateduint256last modified (update) block number of a DID.

getDIDOwner

function getDIDOwner(bytes32 _did) public view returns (address didOwner)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
didOwneraddressthe address of the DID owner.

getDIDRoyaltyRecipient

function getDIDRoyaltyRecipient(bytes32 _did) public view returns (address)

getDIDRoyaltyScheme

function getDIDRoyaltyScheme(bytes32 _did) public view returns (address)

getDIDCreator

function getDIDCreator(bytes32 _did) public view returns (address)

_grantPermission

function _grantPermission(bytes32 _did, address _grantee) internal

_grantPermission grants access permission to grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

_revokePermission

function _revokePermission(bytes32 _did, address _grantee) internal

_revokePermission revokes access permission from grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

_getPermission

function _getPermission(bytes32 _did, address _grantee) internal view returns (bool)

_getPermission gets access permission of a grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress
NameTypeDescription
[0]booltrue if grantee has access permission to a DID

getProvenanceEntry

function getProvenanceEntry(bytes32 _provId) public view returns (bytes32 did, bytes32 relatedDid, address agentId, bytes32 activityId, address agentInvolvedId, uint8 method, address createdBy, uint256 blockNumberUpdated, bytes signature)

Fetch the complete provenance entry attributes

NameTypeDescription
_provIdbytes32refers to the provenance identifier
NameTypeDescription
didbytes32to what DID refers this entry
relatedDidbytes32DID related with the entry
agentIdaddressthe agent identifier
activityIdbytes32referring to the id of the activity
agentInvolvedIdaddressagent involved with the action
methoduint8the w3c provenance method
createdByaddresswho is creating this entry
blockNumberUpdateduint256in which block was updated
signaturebytesdigital signature

isDIDOwner

function isDIDOwner(address _address, bytes32 _did) public view returns (bool)

isDIDOwner check whether a given address is owner for a DID

NameTypeDescription
_addressaddressuser address.
_didbytes32refers to decentralized identifier (a bytes32 length ID).

isOwnerProviderOrDelegate

function isOwnerProviderOrDelegate(bytes32 _did) public view returns (bool)

isOwnerProviderOrDelegate check whether msg.sender is owner, provider or delegate for a DID given

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
[0]boolboolean true if yes

isProvenanceDelegate

function isProvenanceDelegate(bytes32 _did, address _delegate) public view returns (bool)

isProvenanceDelegate check whether a given DID delegate exists

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_delegateaddressdelegate's address.
NameTypeDescription
[0]boolboolean true if yes

getProvenanceOwner

function getProvenanceOwner(bytes32 _did) public view returns (address provenanceOwner)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
provenanceOwneraddressthe address of the Provenance owner.

DIDRegistry

Implementation of a Mintable DID Registry.

erc1155

contract NFTUpgradeable erc1155

erc721

contract NFT721Upgradeable erc721

royaltiesCheckers

mapping(address => bool) royaltiesCheckers

initialize

function initialize(address _owner, address _erc1155, address _erc721) public

DIDRegistry Initializer Initialize Ownable. Only on contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract.
_erc1155address
_erc721address

registerRoyaltiesChecker

function registerRoyaltiesChecker(address _addr) public

DIDRoyaltiesAdded

event DIDRoyaltiesAdded(bytes32 did, address addr)

DIDRoyaltyRecipientChanged

event DIDRoyaltyRecipientChanged(bytes32 did, address addr)

setDIDRoyalties

function setDIDRoyalties(bytes32 _did, address _royalties) public

setDIDRoyaltyRecipient

function setDIDRoyaltyRecipient(bytes32 _did, address _recipient) public

registerMintableDID

function registerMintableDID(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, uint256 _cap, uint8 _royalties, bool _mint, bytes32 _activityId, string _nftMetadata) public

Register a Mintable DID using NFTs based in the ERC-1155 standard.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif true it mints the ERC-1155 NFTs attached to the asset
_activityIdbytes32refers to activity
_nftMetadatastringrefers to the url providing the NFT Metadata

registerMintableDID721

function registerMintableDID721(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, uint8 _royalties, bool _mint, bytes32 _activityId, string _nftMetadata) public

Register a Mintable DID using NFTs based in the ERC-721 standard.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif true it mints the ERC-1155 NFTs attached to the asset
_activityIdbytes32refers to activity
_nftMetadatastringrefers to the url providing the NFT Metadata

registerMintableDID

function registerMintableDID(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, uint256 _cap, uint8 _royalties, bytes32 _activityId, string _nftMetadata) public

Register a Mintable DID.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_activityIdbytes32refers to activity
_nftMetadatastringrefers to the url providing the NFT Metadata

enableAndMintDidNft

function enableAndMintDidNft(bytes32 _did, uint256 _cap, uint8 _royalties, bool _mint, string _nftMetadata) public returns (bool success)

enableDidNft creates the initial setup of NFTs minting and royalties distribution for ERC-1155 NFTs. After this initial setup, this data can't be changed anymore for the DID given, even for the owner of the DID. The reason of this is to avoid minting additional NFTs after the initial agreement, what could affect the valuation of NFTs of a DID already created.

update the DID registry providers list by adding the mintCap and royalties configuration

NameTypeDescription
_didbytes32refers to decentralized identifier (a byte32 length ID)
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif is true mint directly the amount capped tokens and lock in the _lockAddress
_nftMetadatastringrefers to the url providing the NFT Metadata

enableAndMintDidNft721

function enableAndMintDidNft721(bytes32 _did, uint8 _royalties, bool _mint, string _nftMetadata) public returns (bool success)

enableAndMintDidNft721 creates the initial setup of NFTs minting and royalties distribution for ERC-721 NFTs. After this initial setup, this data can't be changed anymore for the DID given, even for the owner of the DID. The reason of this is to avoid minting additional NFTs after the initial agreement, what could affect the valuation of NFTs of a DID already created.

update the DID registry providers list by adding the mintCap and royalties configuration

NameTypeDescription
_didbytes32refers to decentralized identifier (a byte32 length ID)
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif is true mint directly the amount capped tokens and lock in the _lockAddress
_nftMetadatastringrefers to the url providing the NFT Metadata

mint

function mint(bytes32 _did, uint256 _amount, address _receiver) public

Mints a NFT associated to the DID

Because ERC-1155 uses uint256 and DID's are bytes32, there is a conversion between both Only the DID owner can mint NFTs associated to the DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_amountuint256amount to mint
_receiveraddressthe address that will receive the new nfts minted

mint

function mint(bytes32 _did, uint256 _amount) public

mint721

function mint721(bytes32 _did, address _receiver) public

Mints a ERC-721 NFT associated to the DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_receiveraddressthe address that will receive the new nfts minted

mint721

function mint721(bytes32 _did) public

burn

function burn(bytes32 _did, uint256 _amount) public

Burns NFTs associated to the DID

Because ERC-1155 uses uint256 and DID's are bytes32, there is a conversion between both Only the DID owner can burn NFTs associated to the DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_amountuint256amount to burn

burn721

function burn721(bytes32 _did) public

DIDRegistryLibrary

All function calls are currently implemented without side effects

DIDRegister

struct DIDRegister {
address owner;
uint8 royalties;
bool nftInitialized;
bool nft721Initialized;
address creator;
bytes32 lastChecksum;
string url;
address lastUpdatedBy;
uint256 blockNumberUpdated;
address[] providers;
address[] delegates;
uint256 nftSupply;
uint256 mintCap;
address royaltyRecipient;
contract IRoyaltyScheme royaltyScheme;
}

DIDRegisterList

struct DIDRegisterList {
mapping(bytes32 => struct DIDRegistryLibrary.DIDRegister) didRegisters;
bytes32[] didRegisterIds;
}

update

function update(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, bytes32 _checksum, string _url) external

update the DID store

access modifiers and storage pointer should be implemented in DIDRegistry

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_checksumbytes32includes a one-way HASH calculated using the DDO content
_urlstringincludes the url resolving to the DID Document (DDO)

initializeNftConfig

function initializeNftConfig(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, uint256 _cap, uint8 _royalties) internal

initializeNftConfig creates the initial setup of NFTs minting and royalties distribution. After this initial setup, this data can't be changed anymore for the DID given, even for the owner of the DID. The reason of this is to avoid minting additional NFTs after the initial agreement, what could affect the valuation of NFTs of a DID already created.

update the DID registry providers list by adding the mintCap and royalties configuration

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market The royalties in secondary market for the creator should be between 0% >= x < 100%

initializeNft721Config

function initializeNft721Config(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, uint8 _royalties) internal

areRoyaltiesValid

function areRoyaltiesValid(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) internal view returns (bool)

areRoyaltiesValid checks if for a given DID and rewards distribution, this allocate the
original creator royalties properly

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_amountsuint256[]refers to the amounts to reward
_receiversaddress[]refers to the receivers of rewards
_tokenAddressaddress
NameTypeDescription
[0]booltrue if the rewards distribution respect the original creator royalties

addProvider

function addProvider(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address provider) internal

addProvider add provider to DID registry

update the DID registry providers list by adding a new provider

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
provideraddressthe provider's address

removeProvider

function removeProvider(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _provider) internal returns (bool)

removeProvider remove provider from DID registry

update the DID registry providers list by removing an existing provider

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_provideraddressthe provider's address

updateDIDOwner

function updateDIDOwner(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _newOwner) internal

updateDIDOwner transfer DID ownership to a new owner

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_newOwneraddressthe new DID owner address

isProvider

function isProvider(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _provider) public view returns (bool)

isProvider check whether DID provider exists

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_provideraddressthe provider's address
NameTypeDescription
[0]booltrue if the provider already exists

getProviderIndex

function getProviderIndex(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address provider) private view returns (int256)

getProviderIndex get the index of a provider

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
provideraddressthe provider's address
NameTypeDescription
[0]int256the index if the provider exists otherwise return -1

addDelegate

function addDelegate(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address delegate) internal

addDelegate add delegate to DID registry

update the DID registry delegates list by adding a new delegate

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
delegateaddressthe delegate's address

removeDelegate

function removeDelegate(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _delegate) internal returns (bool)

removeDelegate remove delegate from DID registry

update the DID registry delegates list by removing an existing delegate

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_delegateaddressthe delegate's address

isDelegate

function isDelegate(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _delegate) public view returns (bool)

isDelegate check whether DID delegate exists

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_delegateaddressthe delegate's address
NameTypeDescription
[0]booltrue if the delegate already exists

getDelegateIndex

function getDelegateIndex(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address delegate) private view returns (int256)

getDelegateIndex get the index of a delegate

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
delegateaddressthe delegate's address
NameTypeDescription
[0]int256the index if the delegate exists otherwise return -1

ProvenanceRegistry

All function calls are currently implemented without side effects

__ProvenanceRegistry_init

function __ProvenanceRegistry_init() internal

__ProvenanceRegistry_init_unchained

function __ProvenanceRegistry_init_unchained() internal

Provenance

struct Provenance {
bytes32 did;
bytes32 relatedDid;
address agentId;
bytes32 activityId;
address agentInvolvedId;
uint8 method;
address createdBy;
uint256 blockNumberUpdated;
bytes signature;
}

ProvenanceRegistryList

struct ProvenanceRegistryList {
mapping(bytes32 &#x3D;&gt; struct ProvenanceRegistry.Provenance) list;
}

provenanceRegistry

struct ProvenanceRegistry.ProvenanceRegistryList provenanceRegistry

ProvenanceMethod

enum ProvenanceMethod {
ENTITY,
ACTIVITY,
WAS_GENERATED_BY,
USED,
WAS_INFORMED_BY,
WAS_STARTED_BY,
WAS_ENDED_BY,
WAS_INVALIDATED_BY,
WAS_DERIVED_FROM,
AGENT,
WAS_ATTRIBUTED_TO,
WAS_ASSOCIATED_WITH,
ACTED_ON_BEHALF
}

ProvenanceAttributeRegistered

event ProvenanceAttributeRegistered(bytes32 provId, bytes32 _did, address _agentId, bytes32 _activityId, bytes32 _relatedDid, address _agentInvolvedId, enum ProvenanceRegistry.ProvenanceMethod _method, string _attributes, uint256 _blockNumberUpdated)

Provenance Events

WasGeneratedBy

event WasGeneratedBy(bytes32 _did, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

Used

event Used(bytes32 _did, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

WasDerivedFrom

event WasDerivedFrom(bytes32 _newEntityDid, bytes32 _usedEntityDid, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

WasAssociatedWith

event WasAssociatedWith(bytes32 _entityDid, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

ActedOnBehalf

event ActedOnBehalf(bytes32 _entityDid, address _delegateAgentId, address _responsibleAgentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

createProvenanceEntry

function createProvenanceEntry(bytes32 _provId, bytes32 _did, bytes32 _relatedDid, address _agentId, bytes32 _activityId, address _agentInvolvedId, enum ProvenanceRegistry.ProvenanceMethod _method, address _createdBy, bytes _signatureDelegate, string _attributes) internal returns (bool)

create an event in the Provenance store

access modifiers and storage pointer should be implemented in ProvenanceRegistry

NameTypeDescription
_provIdbytes32refers to provenance event identifier
_didbytes32refers to decentralized identifier (a byte32 length ID)
_relatedDidbytes32refers to decentralized identifier (a byte32 length ID) of a related entity
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_agentInvolvedIdaddressrefers to address of the agent involved with the provenance record
_methodenum ProvenanceRegistry.ProvenanceMethodrefers to the W3C Provenance method
_createdByaddressrefers to address of the agent triggering the activity
_signatureDelegatebytesrefers to the digital signature provided by the did delegate.
_attributesstring

_wasGeneratedBy

function _wasGeneratedBy(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) internal virtual returns (bool)

Implements the W3C PROV Generation action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity created
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes
NameTypeDescription
[0]boolthe number of the new provenance size

_used

function _used(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, bytes _signatureUsing, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Usage action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity created
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_signatureUsingbytesrefers to the digital signature provided by the agent using the _did
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

_wasDerivedFrom

function _wasDerivedFrom(bytes32 _provId, bytes32 _newEntityDid, bytes32 _usedEntityDid, address _agentId, bytes32 _activityId, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Derivation action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_newEntityDidbytes32refers to decentralized identifier (a bytes32 length ID) of the entity created
_usedEntityDidbytes32refers to decentralized identifier (a bytes32 length ID) of the entity used to derive the new did
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

_wasAssociatedWith

function _wasAssociatedWith(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Association action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

_actedOnBehalf

function _actedOnBehalf(bytes32 _provId, bytes32 _did, address _delegateAgentId, address _responsibleAgentId, bytes32 _activityId, bytes _signatureDelegate, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Delegation action Each party involved in this method (_delegateAgentId & _responsibleAgentId) must provide a valid signature. The content to sign is a representation of the footprint of the event (_did + _delegateAgentId + _responsibleAgentId + _activityId)

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity
_delegateAgentIdaddressrefers to address acting on behalf of the provenance record
_responsibleAgentIdaddressrefers to address responsible of the provenance record
_activityIdbytes32refers to activity
_signatureDelegatebytesrefers to the digital signature provided by the did delegate.
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

CurveRoyalties

registry

contract DIDRegistry registry

DENOMINATOR

uint256 DENOMINATOR

royalties

mapping(bytes32 => uint256) royalties

initialize

function initialize(address _registry) public

royaltyCurve

function royaltyCurve(uint256 num, uint256 max, uint256 rate) public pure virtual returns (uint256)

setRoyalty

function setRoyalty(bytes32 _did, uint256 _royalty) public

Set royalties for a DID

Can only be called by creator of the DID

NameTypeDescription
_didbytes32DID for which the royalties are set
_royaltyuint256Royalty, the actual royalty will be _royalty / 10000 percent

check

function check(bytes32 _did, uint256[] _amounts, address[] _receivers, address _token) external view returns (bool)

RewardsDistributor

used

mapping(bytes32 => bool) used

receivers

mapping(bytes32 => address[]) receivers

registry

contract DIDRegistry registry

conditionStoreManager

contract ConditionStoreManager conditionStoreManager

escrow

address escrow

initialize

function initialize(address _registry, address _conditionStoreManager, address _escrow) public

setReceivers

function setReceivers(bytes32 _did, address[] _addr) public

set receivers for did

NameTypeDescription
_didbytes32DID
_addraddress[]list of receivers

claimReward

function claimReward(bytes32 _agreementId, bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public

distribute rewards associated with an escrow condition

as paramemeters, it just gets the same parameters as fulfill for escrow condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier

StandardRoyalties

registry

contract DIDRegistry registry

DENOMINATOR

uint256 DENOMINATOR

royalties

mapping(bytes32 => uint256) royalties

initialize

function initialize(address _registry) public

setRoyalty

function setRoyalty(bytes32 _did, uint256 _royalty) public

Set royalties for a DID

Can only be called by creator of the DID

NameTypeDescription
_didbytes32DID for which the royalties are set
_royaltyuint256Royalty, the actual royalty will be _royalty / 10000 percent

check

function check(bytes32 _did, uint256[] _amounts, address[] _receivers, address) external view returns (bool)

AaveCreditTemplate

_Implementation of the Aaven Credit Agreement Template 0. Initialize the agreement

  1. LockNFT - Delegatee locks the NFT
  2. AaveCollateralDeposit - Delegator deposits the collateral into Aave. And approves the delegation flow
  3. AaveBorrowCondition - The Delegatee claim the credit amount from Aave
  4. AaveRepayCondition. Options: 4.a Fulfilled state - The Delegatee pay back the loan (including fee) into Aave and gets back the NFT 4.b Aborted state - The Delegatee doesn't pay the loan in time so the Delegator gets the NFT. The Delegator pays the loan to Aave
  5. TransferNFT. Options: 5.a if AaveRepayCondition was fulfilled, it will allow transfer back to the Delegatee or Borrower 5.b if AaveRepayCondition was aborted, it will allow transfer the NFT to the Delegator or Lender_

didRegistry

contract DIDRegistry didRegistry

nftLockCondition

contract INFTLock nftLockCondition

depositCondition

contract AaveCollateralDepositCondition depositCondition

borrowCondition

contract AaveBorrowCondition borrowCondition

repayCondition

contract AaveRepayCondition repayCondition

transferCondition

contract DistributeNFTCollateralCondition transferCondition

withdrawCondition

contract AaveCollateralWithdrawCondition withdrawCondition

vaultAddress

mapping(bytes32 => address) vaultAddress

nvmFee

uint256 nvmFee

vaultLibrary

address vaultLibrary

VaultCreated

event VaultCreated(address _vaultAddress, address _creator, address _lender, address _borrower)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _nftLockConditionAddress, address _depositConditionAddress, address _borrowConditionAddress, address _repayConditionAddress, address _withdrawCollateralAddress, address _transferConditionAddress, address _vaultLibrary) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access , lock payment and escrow payment conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_nftLockConditionAddressaddressNFT Lock Condition contract address
_depositConditionAddressaddressAave collateral deposit Condition address
_borrowConditionAddressaddressAave borrow deposit Condition address
_repayConditionAddressaddressAave repay credit Condition address
_withdrawCollateralAddressaddress
_transferConditionAddressaddressNFT Transfer Condition address
_vaultLibraryaddress

createVaultAgreement

function createVaultAgreement(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _vaultAddress) public

createAgreement

function createAgreement(bytes32 _id, address _lendingPool, address _dataProvider, address _weth, uint256 _agreementFee, address _treasuryAddress, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _lender) public

deployVault

function deployVault(address _lendingPool, address _dataProvider, address _weth, uint256 _agreementFee, address _treasuryAddress, address _borrower, address _lender) public returns (address)

getVaultForAgreement

function getVaultForAgreement(bytes32 _agreementId) public view returns (address)

updateNVMFee

function updateNVMFee(uint256 _newFee) public

Updates the nevermined fee for this type of agreement

NameTypeDescription
_newFeeuint256New nevermined fee expressed in basis points

changeCreditVaultLibrary

function changeCreditVaultLibrary(address _vaultLibrary) public

AccessProofTemplate

Implementation of Access Agreement Template

didRegistry

contract DIDRegistry didRegistry

accessCondition

contract AccessProofCondition accessCondition

lockCondition

contract LockPaymentCondition lockCondition

escrowReward

contract EscrowPaymentCondition escrowReward

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress, address _accessConditionAddress, address _lockConditionAddress, address payable _escrowConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access , lock payment and escrow payment conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address
_accessConditionAddressaddressaccess condition address
_lockConditionAddressaddresslock reward condition contract address
_escrowConditionAddressaddress payableescrow reward contract address

AccessTemplate

_Implementation of Access Agreement Template

 Access template is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an on-chain SEA. The template is a composite of three basic
conditions. Once the agreement is created, the consumer will lock an amount
of tokens (as listed in the DID document - off-chain metadata) to the
the lock reward contract which in turn will fire an event. ON the other hand
the provider is listening to all the emitted events, the provider
will catch the event and grant permissions to the consumer through
secret store contract, the consumer now is able to download the data set
by asking the off-chain component of secret store to decrypt the DID and
encrypt it using the consumer's public key. Then the secret store will
provide an on-chain proof that the consumer had access to the data set.
Finally, the provider can call the escrow reward condition in order
to release the payment. Every condition has a time window (time lock and
time out). This implies that if the provider didn't grant the access to
the consumer through secret store within this time window, the consumer
can ask for refund._

didRegistry

contract DIDRegistry didRegistry

accessCondition

contract AccessCondition accessCondition

lockCondition

contract LockPaymentCondition lockCondition

escrowReward

contract EscrowPaymentCondition escrowReward

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress, address _accessConditionAddress, address _lockConditionAddress, address payable _escrowConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access , lock payment and escrow payment conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address
_accessConditionAddressaddressaccess condition address
_lockConditionAddressaddresslock reward condition contract address
_escrowConditionAddressaddress payableescrow reward contract address

AgreementTemplate

_Implementation of Agreement Template

 Agreement template is a reference template where it
has the ability to create agreements from whitelisted
template_

conditionTypes

address[] conditionTypes

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts) public

createAgreement create new agreement

NameTypeDescription
_idbytes32agreement unique identifier
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_conditionIdsbytes32[]list of condition identifiers
_timeLocksuint256[]list of time locks, each time lock will be assigned to the same condition that has the same index
_timeOutsuint256[]list of time outs, each time out will be assigned to the same condition that has the same index

createAgreementAndPay

function createAgreementAndPay(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, uint256 _idx, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public payable

createAgreementAndFulfill

function createAgreementAndFulfill(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, uint256[] _indices, address[] _accounts, bytes[] _params) internal

getConditionTypes

function getConditionTypes() public view returns (address[])

getConditionTypes gets the conditions addresses list

for the current template returns list of condition contracts addresses

NameTypeDescription
[0]address[]list of conditions contract addresses

BaseEscrowTemplate

agreementData

struct BaseEscrowTemplate.AgreementData agreementData

AgreementCreated

event AgreementCreated(bytes32 _agreementId, bytes32 _did, address _accessConsumer, address _accessProvider, uint256[] _timeLocks, uint256[] _timeOuts, bytes32[] _conditionIdSeeds, bytes32[] _conditionIds, bytes32 _idSeed, address _creator)

AgreementDataModel

struct AgreementDataModel {
address accessConsumer;
address accessProvider;
bytes32 did;
}

AgreementData

struct AgreementData {
mapping(bytes32 &#x3D;&gt; struct BaseEscrowTemplate.AgreementDataModel) agreementDataItems;
bytes32[] agreementIds;
}

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer) public

createAgreement creates agreements through agreement template

this function initializes the agreement by setting the DID, conditions ID, timeouts, time locks and the consumer address. The DID provider/owner is automatically detected by the DID Registry

NameTypeDescription
_idbytes32SEA agreement unique identifier
_didbytes32Decentralized Identifier (DID)
_conditionIdsbytes32[]conditions ID associated with the condition types
_timeLocksuint256[]the starting point of the time window ,time lock is in block number not seconds
_timeOutsuint256[]the ending point of the time window ,time lock is in block number not seconds
_accessConsumeraddressconsumer address

createAgreementAndPayEscrow

function createAgreementAndPayEscrow(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, uint256 _idx, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public payable

createAgreementAndFulfill

function createAgreementAndFulfill(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, uint256[] _indices, address[] _accounts, bytes[] _params) internal

_makeIds

function _makeIds(bytes32 _idSeed, bytes32[] _conditionIds) internal view returns (bytes32[])

_initAgreement

function _initAgreement(bytes32 _idSeed, bytes32 _did, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, bytes32[] _conditionIds) internal

getAgreementData

function getAgreementData(bytes32 _id) external view returns (address accessConsumer, address accessProvider)

getAgreementData return the agreement Data

NameTypeDescription
_idbytes32SEA agreement unique identifier
NameTypeDescription
accessConsumeraddressthe agreement consumer
accessProvideraddressthe provider addresses

DIDSalesTemplate

_Implementation of DID Sales Template

 The DID Sales template supports an scenario where an Asset owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing an Asset owner to get transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer DID Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the ownership transfer of an asset
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

transferCondition

contract TransferDIDOwnershipCondition transferCondition

rewardCondition

contract EscrowPaymentCondition rewardCondition

id

function id() public pure returns (uint256)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockConditionAddress, address _transferConditionAddress, address payable _escrowPaymentAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockConditionAddressaddresslock reward condition contract address
_transferConditionAddressaddresstransfer ownership condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address

DynamicAccessTemplate

Implementation of Agreement Template This is a dynamic template that allows to setup flexible conditions depending on the use case.

didRegistry

contract DIDRegistry didRegistry

templateConfig

struct DynamicAccessTemplate.TemplateConditions templateConfig

TemplateConditions

struct TemplateConditions {
mapping(address &#x3D;&gt; contract Condition) templateConditions;
}

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address

addTemplateCondition

function addTemplateCondition(address _conditionAddress) external returns (uint256 length)

addTemplateCondition adds a new condition to the template

NameTypeDescription
_conditionAddressaddresscondition contract address
NameTypeDescription
lengthuint256conditionTypes array size

removeLastTemplateCondition

function removeLastTemplateCondition() external returns (address[])

removeLastTemplateCondition removes last condition added to the template

NameTypeDescription
[0]address[]conditionTypes existing in the array

EscrowComputeExecutionTemplate

_Implementation of a Compute Execution Agreement Template

 EscrowComputeExecutionTemplate is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an on-chain SEA. The template is a composite of three basic
conditions. Once the agreement is created, the consumer will lock an amount
of tokens (as listed in the DID document - off-chain metadata) to the
the lock reward contract which in turn will fire an event. ON the other hand
the provider is listening to all the emitted events, the provider
will catch the event and grant permissions to trigger a computation granting
the execution via the ComputeExecutionCondition contract.
The consumer now is able to trigger that computation
by asking the off-chain gateway to start the execution of a compute workflow.
Finally, the provider can call the escrow reward condition in order
to release the payment. Every condition has a time window (time lock and
time out). This implies that if the provider didn't grant the execution to
the consumer within this time window, the consumer
can ask for refund._

didRegistry

contract DIDRegistry didRegistry

computeExecutionCondition

contract ComputeExecutionCondition computeExecutionCondition

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

escrowPayment

contract EscrowPaymentCondition escrowPayment

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress, address _computeExecutionConditionAddress, address _lockPaymentConditionAddress, address payable _escrowPaymentAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including service executor condition, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address
_computeExecutionConditionAddressaddressservice executor condition contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_escrowPaymentAddressaddress payableescrow reward contract address

name

function name() public pure returns (string)

NFT721AccessProofTemplate

Implementation of NFT721 Access Proof Template

NFT721AccessSwapTemplate

NFT721AccessTemplate

Implementation of NFT Access Template

NFT721SalesTemplate

Implementation of NFT Sales Template

NFT721SalesWithAccessTemplate

NFTAccessProofTemplate

_Implementation of NFT Access Template

 The NFT Access template is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing NFT holders to get access to Nevermined services.
The template is a composite of 2 basic conditions:
- NFT Holding Condition
- Access Condition

Once the agreement is created, the consumer can demonstrate is holding a NFT
for a specific DID. If that's the case the Access condition can be fulfilled
by the asset owner or provider and all the agreement is fulfilled.
This can be used in scenarios where a data or services owner, can allow
users to get access to exclusive services only when they demonstrate the
are holding a specific number of NFTs of a DID.
This is very useful in use cases like arts._

didRegistry

contract DIDRegistry didRegistry

nftHolderCondition

contract INFTHolder nftHolderCondition

accessCondition

contract AccessProofCondition accessCondition

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _nftHolderConditionAddress, address _accessConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_nftHolderConditionAddressaddresslock reward condition contract address
_accessConditionAddressaddressaccess condition contract address

NFTAccessSwapTemplate

_Implementation of NFT Sales Template

 The NFT Sales template supports an scenario where a NFT owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing a NFT owner to transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer NFT Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the transfer of the NFT
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract INFTLock lockPaymentCondition

rewardCondition

contract INFTEscrow rewardCondition

accessCondition

contract AccessProofCondition accessCondition

id

function id() public pure returns (uint256)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockPaymentConditionAddress, address payable _escrowPaymentAddress, address _accessCondition) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address
_accessConditionaddress

NFTAccessTemplate

_Implementation of NFT Access Template

 The NFT Access template is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing NFT holders to get access to Nevermined services.
The template is a composite of 2 basic conditions:
- NFT Holding Condition
- Access Condition

Once the agreement is created, the consumer can demonstrate is holding a NFT
for a specific DID. If that's the case the Access condition can be fulfilled
by the asset owner or provider and all the agreement is fulfilled.
This can be used in scenarios where a data or services owner, can allow
users to get access to exclusive services only when they demonstrate the
are holding a specific number of NFTs of a DID.
This is very useful in use cases like arts._

didRegistry

contract DIDRegistry didRegistry

nftHolderCondition

contract INFTHolder nftHolderCondition

accessCondition

contract INFTAccess accessCondition

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _nftHolderConditionAddress, address _accessConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_nftHolderConditionAddressaddresslock reward condition contract address
_accessConditionAddressaddressaccess condition contract address

NFTSalesTemplate

_Implementation of NFT Sales Template

 The NFT Sales template supports an scenario where a NFT owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing a NFT owner to transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer NFT Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the transfer of the NFT
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

transferCondition

contract ITransferNFT transferCondition

rewardCondition

contract EscrowPaymentCondition rewardCondition

id

function id() public pure returns (uint256)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockPaymentConditionAddress, address _transferConditionAddress, address payable _escrowPaymentAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_transferConditionAddressaddresstransfer NFT condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address

nftPrice

mapping(address => mapping(address => mapping(address => mapping(bytes32 => uint256)))) nftPrice

nftSale

function nftSale(address nftAddress, bytes32 nftId, address token, uint256 amount) external

checkParamsTransfer

function checkParamsTransfer(bytes[] _params, bytes32 lockPaymentConditionId, bytes32 _did) internal view returns (address)

checkParamsEscrow

function checkParamsEscrow(bytes[] _params, bytes32 lockPaymentId, bytes32 transferId) internal pure

createAgreementFulfill

function createAgreementFulfill(bytes32 _id, bytes32 _did, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, bytes[] _params) external payable

NFTSalesWithAccessTemplate

_Implementation of NFT Sales Template

 The NFT Sales template supports an scenario where a NFT owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing a NFT owner to transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer NFT Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the transfer of the NFT
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

transferCondition

contract ITransferNFT transferCondition

rewardCondition

contract EscrowPaymentCondition rewardCondition

accessCondition

contract AccessProofCondition accessCondition

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockPaymentConditionAddress, address _transferConditionAddress, address payable _escrowPaymentAddress, address _accessCondition) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_transferConditionAddressaddresstransfer NFT condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address
_accessConditionaddress

TemplateStoreLibrary

_Implementation of the Template Store Library.

 Templates are blueprints for modular SEAs. When 
creating an Agreement, a templateId defines the condition
and reward types that are instantiated in the ConditionStore._

TemplateState

enum TemplateState {
Uninitialized,
Proposed,
Approved,
Revoked
}

Template

struct Template {
enum TemplateStoreLibrary.TemplateState state;
address owner;
address lastUpdatedBy;
uint256 blockNumberUpdated;
}

TemplateList

struct TemplateList {
mapping(address &#x3D;&gt; struct TemplateStoreLibrary.Template) templates;
address[] templateIds;
}

propose

function propose(struct TemplateStoreLibrary.TemplateList _self, address _id) internal returns (uint256 size)

propose new template

NameTypeDescription
_selfstruct TemplateStoreLibrary.TemplateListis the TemplateList storage pointer
_idaddressproposed template contract address
NameTypeDescription
sizeuint256which is the index of the proposed template

approve

function approve(struct TemplateStoreLibrary.TemplateList _self, address _id) internal

approve new template

NameTypeDescription
_selfstruct TemplateStoreLibrary.TemplateListis the TemplateList storage pointer
_idaddressproposed template contract address

revoke

function revoke(struct TemplateStoreLibrary.TemplateList _self, address _id) internal

revoke new template

NameTypeDescription
_selfstruct TemplateStoreLibrary.TemplateListis the TemplateList storage pointer
_idaddressapproved template contract address

TemplateStoreManager

Implementation of the Template Store Manager. Templates are blueprints for modular SEAs. When creating an Agreement, a templateId defines the condition and reward types that are instantiated in the ConditionStore. This contract manages the life cycle of the template ( Propose --> Approve --> Revoke ).

templateList

struct TemplateStoreLibrary.TemplateList templateList

onlyOwnerOrTemplateOwner

modifier onlyOwnerOrTemplateOwner(address _id)

initialize

function initialize(address _owner) public

initialize TemplateStoreManager Initializer Initializes Ownable. Only on contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract

proposeTemplate

function proposeTemplate(address _id) external returns (uint256 size)

proposeTemplate proposes a new template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address

approveTemplate

function approveTemplate(address _id) external

approveTemplate approves a template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address. Only template store manager owner (i.e OPNF) can approve this template.

revokeTemplate

function revokeTemplate(address _id) external

revokeTemplate revoke a template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address. Only template store manager owner (i.e OPNF) or template owner can revoke this template.

getTemplate

function getTemplate(address _id) external view returns (enum TemplateStoreLibrary.TemplateState state, address owner, address lastUpdatedBy, uint256 blockNumberUpdated)

getTemplate get more information about a template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address.
NameTypeDescription
stateenum TemplateStoreLibrary.TemplateStatetemplate status
owneraddresstemplate owner
lastUpdatedByaddresslast updated by
blockNumberUpdateduint256last updated at.

getTemplateListSize

function getTemplateListSize() external view virtual returns (uint256 size)

getTemplateListSize number of templates

NameTypeDescription
sizeuint256number of templates

isTemplateApproved

function isTemplateApproved(address _id) external view returns (bool)

isTemplateApproved check whether the template is approved

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address.
NameTypeDescription
[0]booltrue if the template is approved

AgreementStoreManagerChangeFunctionSignature

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, address[] _conditionTypes, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _creator, address _sender) public

AgreementStoreManagerChangeInStorage

agreementCount

uint256 agreementCount

AgreementStoreManagerChangeInStorageAndLogic

AgreementStoreManagerExtraFunctionality

dummyFunction

function dummyFunction() public pure returns (bool)

AgreementStoreManagerWithBug

getDIDRegistryAddress

function getDIDRegistryAddress() public pure returns (address)

getDIDRegistryAddress utility function used by other contracts or any EOA.

NameTypeDescription
[0]addressthe DIDRegistry address

ConditionStoreChangeFunctionSignature

createCondition

function createCondition(bytes32 _id, address _typeRef, address _sender) public

ConditionStoreChangeInStorage

conditionCount

uint256 conditionCount

ConditionStoreChangeInStorageAndLogic

ConditionStoreExtraFunctionality

dummyFunction

function dummyFunction() public pure returns (bool)

ConditionStoreWithBug

getConditionState

function getConditionState(bytes32 _id) public view returns (enum ConditionStoreLibrary.ConditionState)

getConditionState

NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

DIDRegistryChangeFunctionSignature

registerAttribute

function registerAttribute(bytes32 _didSeed, address[] _providers, bytes32 _checksum, string _url) public

DIDRegistryChangeInStorage

timeOfRegister

mapping(bytes32 => uint256) timeOfRegister

DIDRegistryChangeInStorageAndLogic

DIDRegistryExtraFunctionality

getNumber

function getNumber() public pure returns (uint256)

DIDRegistryWithBug

registerAttribute

function registerAttribute(bytes32 _checksum, bytes32 _didSeed, address[] _providers, string _url) public

registerAttribute is called only by DID owner.

this function registers DID attributes

NameTypeDescription
_checksumbytes32includes a one-way HASH calculated using the DDO content
_didSeedbytes32refers to decentralized identifier (a byte32 length ID)
_providersaddress[]
_urlstringrefers to the attribute value

IPNFT

TokenURIChanged

event TokenURIChanged(uint256 tokenId, string newURI)

initialize

function initialize(string _name, string _symbol) public

setTokenURI

function setTokenURI(uint256 tokenId, string _tokenURI) public

mint

function mint(address to, uint256 _tokenId, string _tokenURI) public returns (bool)

mintWithoutTokenURI

function mintWithoutTokenURI(address to, uint256 _tokenId) external

transfer

function transfer(address from, address to, uint256 _tokenId) public

NeverminedConfigChangeInStorage

newVariable

uint256 newVariable

NeverminedConfigChangeFunctionSignature

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver, uint256 _newParameter) external virtual

NeverminedConfigChangeInStorageAndLogic

NeverminedConfigWithBug

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver) external virtual

The governor can update the Nevermined Marketplace fees

NameTypeDescription
_marketplaceFeeuint256new marketplace fee
_feeReceiveraddressThe address receiving the fee

TemplateStoreChangeFunctionSignature

proposeTemplate

function proposeTemplate(address _id, address _sender) external returns (uint256 size)

TemplateStoreChangeInStorage

templateCount

uint256 templateCount

TemplateStoreChangeInStorageAndLogic

TemplateStoreExtraFunctionality

dummyFunction

function dummyFunction() public pure returns (bool)

TemplateStoreWithBug

getTemplateListSize

function getTemplateListSize() external view returns (uint256 size)

getTemplateListSize number of templates

NameTypeDescription
sizeuint256number of templates

TestERC721

initialize

function initialize() public

mint

function mint(uint256 id) public

DIDRegistryLibraryProxy

didRegister

struct DIDRegistryLibrary.DIDRegister didRegister

didRegisterList

struct DIDRegistryLibrary.DIDRegisterList didRegisterList

areRoyaltiesValid

function areRoyaltiesValid(bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) public view returns (bool)

updateDIDOwner

function updateDIDOwner(bytes32 _did, address _newOwner) public

update

function update(bytes32 _did, bytes32 _checksum, string _url) public

initializeNftConfig

function initializeNftConfig(bytes32 _did, uint256 _cap, uint8 _royalties) public

initializeNft721Config

function initializeNft721Config(bytes32 _did, uint8 _royalties) public

getDIDInfo

function getDIDInfo(bytes32 _did) public view returns (address owner, address creator, uint256 royalties)

EpochLibraryProxy

epoch

struct EpochLibrary.Epoch epoch

epochList

struct EpochLibrary.EpochList epochList

create

function create(bytes32 _id, uint256 _timeLock, uint256 _timeOut) external

HashListLibraryProxy

testData

struct HashListLibrary.List testData

initialize

function initialize(address _owner) public

hash

function hash(address _address) public pure returns (bytes32)

add

function add(bytes32[] values) external returns (bool)

add

function add(bytes32 value) external returns (bool)

update

function update(bytes32 oldValue, bytes32 newValue) external returns (bool)

index

function index(uint256 from, uint256 to) external returns (bool)

has

function has(bytes32 value) external view returns (bool)

remove

function remove(bytes32 value) external returns (bool)

get

function get(uint256 _index) external view returns (bytes32)

size

function size() external view returns (uint256)

all

function all() external view returns (bytes32[])

indexOf

function indexOf(bytes32 value) external view returns (uint256)

ownedBy

function ownedBy() external view returns (address)

isIndexed

function isIndexed() external view returns (bool)

NFTBase

Implementation of the Royalties EIP-2981 base contract See https://eips.ethereum.org/EIPS/eip-2981

_proxyApprovals

mapping(address => bool) _proxyApprovals

MINTER_ROLE

bytes32 MINTER_ROLE

RoyaltyInfo

struct RoyaltyInfo {
address receiver;
uint256 royaltyAmount;
}

NFTMetadata

struct NFTMetadata {
string nftURI;
}

_royalties

mapping(uint256 => struct NFTBase.RoyaltyInfo) _royalties

_metadata

mapping(uint256 => struct NFTBase.NFTMetadata) _metadata

_expiration

mapping(address => uint256) _expiration

ProxyApproval

event ProxyApproval(address sender, address operator, bool approved)

Event for recording proxy approvals.

setProxyApproval

function setProxyApproval(address operator, bool approved) public virtual

_setNFTMetadata

function _setNFTMetadata(uint256 tokenId, string tokenURI) internal

_setTokenRoyalty

function _setTokenRoyalty(uint256 tokenId, address receiver, uint256 royaltyAmount) internal

royaltyInfo

function royaltyInfo(uint256 tokenId, uint256 value) external view returns (address receiver, uint256 royaltyAmount)

@inheritdoc IERC2981Upgradeable

NFTUpgradeable

Implementation of the basic standard multi-token. See https://eips.ethereum.org/EIPS/eip-1155

initialize

function initialize(string uri_) public

See {_setURI}.

isApprovedForAll

function isApprovedForAll(address account, address operator) public view virtual returns (bool)

See {IERC1155-isApprovedForAll}.

mint

function mint(address to, uint256 id, uint256 amount, bytes data) public

burn

function burn(address to, uint256 id, uint256 amount) public

addMinter

function addMinter(address account) public

uri

function uri(uint256 tokenId) public view returns (string)

setNFTMetadata

function setNFTMetadata(uint256 tokenId, string nftURI) public

Record some NFT Metadata

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
nftURIstringthe URI (https, ipfs, etc) to the metadata describing the NFT

setTokenRoyalty

function setTokenRoyalty(uint256 tokenId, address receiver, uint256 royaltyAmount) public

Record the asset royalties

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
receiveraddressthe receiver of the royalties (the original creator)
royaltyAmountuint256percentage (no decimals, between 0 and 100)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

NFT721SubscriptionUpgradeable

mint

function mint(address to, uint256 id, uint256 expirationBlock) public

_This mint function allows to define when the NFT expires. The minter should calculate this block number depending on the network velocity

TransferNFT721Condition needs to have the MINTER_ROLE_

balanceOf

function balanceOf(address owner) public view returns (uint256)

See {IERC721-balanceOf}.

NFT721Upgradeable

Implementation of the basic standard multi-token.

initialize

function initialize(string name, string symbol) public virtual

initialize

function initialize() public virtual

isApprovedForAll

function isApprovedForAll(address account, address operator) public view virtual returns (bool)

See {IERC1155-isApprovedForAll}.

addMinter

function addMinter(address account) public

mint

function mint(address to, uint256 id) public virtual

burn

function burn(uint256 id) public

tokenURI

function tokenURI(uint256 tokenId) public view virtual returns (string)

See {IERC721Metadata-tokenURI}.

setNFTMetadata

function setNFTMetadata(uint256 tokenId, string nftURI) public

Record some NFT Metadata

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
nftURIstringthe URI (https, ipfs, etc) to the metadata describing the NFT

setTokenRoyalty

function setTokenRoyalty(uint256 tokenId, address receiver, uint256 royaltyAmount) public

Record the asset royalties

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
receiveraddressthe receiver of the royalties (the original creator)
royaltyAmountuint256percentage (no decimals, between 0 and 100)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

POAPUpgradeable

_tokenIdCounter

struct CountersUpgradeable.Counter _tokenIdCounter

_tokenEvent

mapping(uint256 => uint256) _tokenEvent

initialize

function initialize() public

initialize

function initialize(string name, string symbol) public virtual

mint

function mint(address to, string uri, uint256 eventId) public

mint

function mint(address to, uint256 id) public

tokenEvent

function tokenEvent(uint256 tokenId) public view returns (uint256)

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal

_burn

function _burn(uint256 tokenId) internal

tokenDetailsOfOwner

function tokenDetailsOfOwner(address owner) public view returns (uint256[] tokenIds, uint256[] eventIds)

tokenURI

function tokenURI(uint256 tokenId) public view returns (string)

isApprovedForAll

function isApprovedForAll(address account, address operator) public view returns (bool)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

PlonkVerifier

n

uint32 n

nPublic

uint16 nPublic

nLagrange

uint16 nLagrange

Qmx

uint256 Qmx

Qmy

uint256 Qmy

Qlx

uint256 Qlx

Qly

uint256 Qly

Qrx

uint256 Qrx

Qry

uint256 Qry

Qox

uint256 Qox

Qoy

uint256 Qoy

Qcx

uint256 Qcx

Qcy

uint256 Qcy

S1x

uint256 S1x

S1y

uint256 S1y

S2x

uint256 S2x

S2y

uint256 S2y

S3x

uint256 S3x

S3y

uint256 S3y

k1

uint256 k1

k2

uint256 k2

X2x1

uint256 X2x1

X2x2

uint256 X2x2

X2y1

uint256 X2y1

X2y2

uint256 X2y2

q

uint256 q

qf

uint256 qf

w1

uint256 w1

G1x

uint256 G1x

G1y

uint256 G1y

G2x1

uint256 G2x1

G2x2

uint256 G2x2

G2y1

uint256 G2y1

G2y2

uint256 G2y2

pA

uint16 pA

pB

uint16 pB

pC

uint16 pC

pZ

uint16 pZ

pT1

uint16 pT1

pT2

uint16 pT2

pT3

uint16 pT3

pWxi

uint16 pWxi

pWxiw

uint16 pWxiw

pEval_a

uint16 pEval_a

pEval_b

uint16 pEval_b

pEval_c

uint16 pEval_c

pEval_s1

uint16 pEval_s1

pEval_s2

uint16 pEval_s2

pEval_zw

uint16 pEval_zw

pEval_r

uint16 pEval_r

pAlpha

uint16 pAlpha

pBeta

uint16 pBeta

pGamma

uint16 pGamma

pXi

uint16 pXi

pXin

uint16 pXin

pBetaXi

uint16 pBetaXi

pV1

uint16 pV1

pV2

uint16 pV2

pV3

uint16 pV3

pV4

uint16 pV4

pV5

uint16 pV5

pV6

uint16 pV6

pU

uint16 pU

pPl

uint16 pPl

pEval_t

uint16 pEval_t

pA1

uint16 pA1

pB1

uint16 pB1

pZh

uint16 pZh

pZhInv

uint16 pZhInv

pEval_l1

uint16 pEval_l1

pEval_l2

uint16 pEval_l2

pEval_l3

uint16 pEval_l3

pEval_l4

uint16 pEval_l4

pEval_l5

uint16 pEval_l5

pEval_l6

uint16 pEval_l6

pEval_l7

uint16 pEval_l7

lastMem

uint16 lastMem

verifyProof

function verifyProof(bytes proof, uint256[] pubSignals) public view returns (bool)

Solidity API

Common

getCurrentBlockNumber

function getCurrentBlockNumber() external view returns (uint256)

getCurrentBlockNumber get block number

NameTypeDescription
[0]uint256the current block number

isContract

function isContract(address addr) public view returns (bool)

isContract detect whether the address is is a contract address or externally owned account

NameTypeDescription
[0]booltrue if it is a contract address

provenanceSignatureIsCorrect

function provenanceSignatureIsCorrect(address _agentId, bytes32 _hash, bytes _signature) public pure returns (bool)
NameTypeDescription
_agentIdaddressThe address of the agent
_hashbytes32bytes32 message, the hash is the signed message. What is recovered is the signer address.
_signaturebytesSignatures provided by the agent
NameTypeDescription
[0]booltrue if the signature correspond to the agent address

calculateTotalAmount

function calculateTotalAmount(uint256[] _amounts) public pure returns (uint256)

Sum the total amount given an uint array

NameTypeDescription
[0]uint256the total amount

addressToBytes32

function addressToBytes32(address _addr) public pure returns (bytes32)

bytes32ToAddress

function bytes32ToAddress(bytes32 _b32) public pure returns (address)

Dispenser

tokenRequests

mapping(address => uint256) tokenRequests

totalMintAmount

uint256 totalMintAmount

maxAmount

uint256 maxAmount

maxMintAmount

uint256 maxMintAmount

minPeriod

uint256 minPeriod

scale

uint256 scale

token

contract NeverminedToken token

RequestFrequencyExceeded

event RequestFrequencyExceeded(address requester, uint256 minPeriod)

RequestLimitExceeded

event RequestLimitExceeded(address requester, uint256 amount, uint256 maxAmount)

isValidAddress

modifier isValidAddress(address _address)

initialize

function initialize(address _tokenAddress, address _owner) external

Dispenser Initializer

NameTypeDescription
_tokenAddressaddressThe deployed contract address of an ERC20
_owneraddressThe owner of the Dispenser Runs only on initial contract creation.

requestTokens

function requestTokens(uint256 amount) external returns (bool tokensTransferred)

user can request some tokens for testing

NameTypeDescription
amountuint256the amount of tokens to be requested
NameTypeDescription
tokensTransferredboolBoolean indication of tokens are requested

setMinPeriod

function setMinPeriod(uint256 period) external

the Owner can set the min period for token requests

NameTypeDescription
perioduint256the min amount of time before next request

setMaxAmount

function setMaxAmount(uint256 amount) external

the Owner can set the max amount for token requests

NameTypeDescription
amountuint256the max amount of tokens that can be requested

setMaxMintAmount

function setMaxMintAmount(uint256 amount) external

the Owner can set the max amount for token requests

NameTypeDescription
amountuint256the max amount of tokens that can be requested

HashLists

Hash lists contract is a sample list contract in which uses HashListLibrary.sol in order to store, retrieve, remove, and update bytes32 values in hash lists. This is a reference implementation for IList interface. It is used for whitelisting condition. Any entity can have its own implementation of the interface in which could be used for the same condition.

lists

mapping(bytes32 => struct HashListLibrary.List) lists

initialize

function initialize(address _owner) public

HashLists Initializer

NameTypeDescription
_owneraddressThe owner of the hash list Runs only upon contract creation.

hash

function hash(address account) public pure returns (bytes32)

hash ethereum accounts

NameTypeDescription
accountaddressEthereum address
NameTypeDescription
[0]bytes32bytes32 hash of the account

add

function add(bytes32[] values) external returns (bool)

put an array of elements without indexing this meant to save gas in case of large arrays

NameTypeDescription
valuesbytes32[]is an array of elements value
NameTypeDescription
[0]booltrue if values are added successfully

add

function add(bytes32 value) external returns (bool)

add indexes an element then adds it to a list

NameTypeDescription
valuebytes32is a bytes32 value
NameTypeDescription
[0]booltrue if value is added successfully

update

function update(bytes32 oldValue, bytes32 newValue) external returns (bool)

update the value with a new value and maintain indices

NameTypeDescription
oldValuebytes32is an element value in a list
newValuebytes32new value
NameTypeDescription
[0]booltrue if value is updated successfully

index

function index(uint256 from, uint256 to) external returns (bool)

index is used to map each element value to its index on the list

NameTypeDescription
fromuint256index is where to 'from' indexing in the list
touint256index is where to stop indexing
NameTypeDescription
[0]booltrue if the sub list is indexed

has

function has(bytes32 id, bytes32 value) external view returns (bool)

has checks whether a value is exist

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
valuebytes32is element value in list
NameTypeDescription
[0]booltrue if the value exists

has

function has(bytes32 value) external view returns (bool)

has checks whether a value is exist

NameTypeDescription
valuebytes32is element value in list
NameTypeDescription
[0]booltrue if the value exists

remove

function remove(bytes32 value) external returns (bool)

remove value from a list, updates indices, and list size

NameTypeDescription
valuebytes32is an element value in a list
NameTypeDescription
[0]booltrue if value is removed successfully

get

function get(bytes32 id, uint256 _index) external view returns (bytes32)

has value by index

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
_indexuint256is where is value is stored in the list
NameTypeDescription
[0]bytes32the value if exists

size

function size(bytes32 id) external view returns (uint256)

size gets the list size

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]uint256total length of the list

all

function all(bytes32 id) external view returns (bytes32[])

all returns all list elements

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]bytes32[]all list elements

indexOf

function indexOf(bytes32 id, bytes32 value) external view returns (uint256)

indexOf gets the index of a value in a list

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
valuebytes32is element value in list
NameTypeDescription
[0]uint256value index in list

ownedBy

function ownedBy(bytes32 id) external view returns (address)

ownedBy gets the list owner

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]addresslist owner

isIndexed

function isIndexed(bytes32 id) external view returns (bool)

isIndexed checks if the list is indexed

NameTypeDescription
idbytes32the list identifier (the hash of list owner's address)
NameTypeDescription
[0]booltrue if the list is indexed

NeverminedToken

Implementation of a Test Token. Test Token is an ERC20 token only for testing purposes

initialize

function initialize(address _owner, address payable _initialMinter) public

NeverminedToken Initializer Runs only on initial contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract
_initialMinteraddress payableis the first token minter added

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 amount) internal

_See {ERC20-_beforeTokenTransfer}.

Requirements:

  • minted tokens must not cause the total supply to go over the cap._

mint

function mint(address account, uint256 amount) external returns (bool)

_Creates amount tokens and assigns them to account, increasing the total supply.

Emits a {Transfer} event with from set to the zero address.

Requirements:

  • to cannot be the zero address._

AgreementStoreLibrary

Implementation of the Agreement Store Library. The agreement store library holds the business logic in which manages the life cycle of SEA agreement, each agreement is linked to the DID of an asset, template, and condition IDs.

Agreement

struct Agreement {
bytes32 did;
address templateId;
bytes32[] conditionIds;
address lastUpdatedBy;
uint256 blockNumberUpdated;
}

AgreementList

struct AgreementList {
mapping(bytes32 &#x3D;&gt; struct AgreementStoreLibrary.Agreement) agreements;
mapping(bytes32 &#x3D;&gt; bytes32[]) didToAgreementIds;
mapping(address &#x3D;&gt; bytes32[]) templateIdToAgreementIds;
bytes32[] agreementIds;
}

create

function create(struct AgreementStoreLibrary.AgreementList _self, bytes32 _id, bytes32, address _templateId, bytes32[]) internal

create new agreement checks whether the agreement Id exists, creates new agreement instance, including the template, conditions and DID.

NameTypeDescription
_selfstruct AgreementStoreLibrary.AgreementListis AgreementList storage pointer
_idbytes32agreement identifier
bytes32
_templateIdaddresstemplate identifier
bytes32[]

Template

getConditionTypes

function getConditionTypes() external view returns (address[])

AgreementStoreManager

_Implementation of the Agreement Store.

 The agreement store generates conditions for an agreement template.
Agreement templates must to be approved in the Template Store
Each agreement is linked to the DID of an asset._

PROXY_ROLE

bytes32 PROXY_ROLE

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

agreementList

struct AgreementStoreLibrary.AgreementList agreementList

state storage for the agreements

conditionStoreManager

contract ConditionStoreManager conditionStoreManager

templateStoreManager

contract TemplateStoreManager templateStoreManager

didRegistry

contract DIDRegistry didRegistry

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _templateStoreManagerAddress, address _didRegistryAddress) public

initialize AgreementStoreManager Initializer Initializes Ownable. Only on contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract
_conditionStoreManagerAddressaddressis the address of the connected condition store
_templateStoreManagerAddressaddressis the address of the connected template store
_didRegistryAddressaddressis the address of the connected DID Registry

fullConditionId

function fullConditionId(bytes32 _agreementId, address _condType, bytes32 _valueHash) public pure returns (bytes32)

agreementId

function agreementId(bytes32 _agreementId, address _creator) public pure returns (bytes32)

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, address[] _conditionTypes, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts) public

Create a new agreement. The agreement will create conditions of conditionType with conditionId. Only "approved" templates can access this function.

NameTypeDescription
_idbytes32is the ID of the new agreement. Must be unique.
_didbytes32is the bytes32 DID of the asset. The DID must be registered beforehand.
_conditionTypesaddress[]is a list of addresses that point to Condition contracts.
_conditionIdsbytes32[]is a list of bytes32 content-addressed Condition IDs
_timeLocksuint256[]is a list of uint time lock values associated to each Condition
_timeOutsuint256[]is a list of uint time out values associated to each Condition

CreateAgreementArgs

struct CreateAgreementArgs {
bytes32 _id;
bytes32 _did;
address[] _conditionTypes;
bytes32[] _conditionIds;
uint256[] _timeLocks;
uint256[] _timeOuts;
address _creator;
uint256 _idx;
address payable _rewardAddress;
address _tokenAddress;
uint256[] _amounts;
address[] _receivers;
}

createAgreementAndPay

function createAgreementAndPay(struct AgreementStoreManager.CreateAgreementArgs args) public payable

createAgreementAndFulfill

function createAgreementAndFulfill(bytes32 _id, bytes32 _did, address[] _conditionTypes, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address[] _account, uint256[] _idx, bytes[] params) public payable

getAgreementTemplate

function getAgreementTemplate(bytes32 _id) external view returns (address)

getDIDRegistryAddress

function getDIDRegistryAddress() public view virtual returns (address)

getDIDRegistryAddress utility function used by other contracts or any EOA.

NameTypeDescription
[0]addressthe DIDRegistry address

AccessCondition

_Implementation of the Access Condition

 Access Secret Store Condition is special condition
where a client or Parity secret store can encrypt/decrypt documents
based on the on-chain granted permissions. For a given DID
document, and agreement ID, the owner/provider of the DID
will fulfill the condition. Consequently secret store
will check whether the permission is granted for the consumer
in order to encrypt/decrypt the document._

CONDITION_TYPE

bytes32 CONDITION_TYPE

DocumentPermission

struct DocumentPermission {
bytes32 agreementIdDeprecated;
mapping(address &#x3D;&gt; bool) permission;
}

documentPermissions

mapping(bytes32 => struct AccessCondition.DocumentPermission) documentPermissions

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

didRegistry

contract DIDRegistry didRegistry

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _documentId, address _grantee, bytes32 _conditionId)

onlyDIDOwnerOrProvider

modifier onlyDIDOwnerOrProvider(bytes32 _documentId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _agreementStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_agreementStoreManagerAddressaddressagreement store manager address

reinitialize

function reinitialize() external

Should be called when the contract has been upgraded.

hashValues

function hashValues(bytes32 _documentId, address _grantee) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill access secret store condition

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

grantPermission

function grantPermission(address _grantee, bytes32 _documentId) public

grantPermission is called only by DID owner or provider

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys

renouncePermission

function renouncePermission(address _grantee, bytes32 _documentId) public

renouncePermission is called only by DID owner or provider

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys

checkPermissions

function checkPermissions(address _grantee, bytes32 _documentId) external view returns (bool permissionGranted)

checkPermissions is called by Parity secret store

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
NameTypeDescription
permissionGrantedbooltrue if the access was granted

IDisputeManager

verifyProof

function verifyProof(bytes proof, uint256[] pubSignals) external view returns (bool)

AccessProofCondition

Implementation of the Access Condition with transfer proof. The idea is that the hash of the decryption key is known before hand, and the key matching this hash is passed from data provider to the buyer using this smart contract. Using ZK proof the key is kept hidden from outsiders. For the protocol to work, both the provider and buyer need to have public keys in the babyjub curve. To initiate the deal, buyer will pass the key hash and the public keys of participants. The provider needs to pass the cipher text encrypted using MIMC (symmetric encryption). The secret key for MIMC is computed using ECDH (requires one public key and one secret key for the curve). The hash function that is used is Poseidon.

CONDITION_TYPE

bytes32 CONDITION_TYPE

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

disputeManager

contract IDisputeManager disputeManager

Fulfilled

event Fulfilled(bytes32 _agreementId, uint256 _origHash, uint256[2] _buyer, uint256[2] _provider, uint256[2] _cipher, bytes _proof, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _agreementStoreManagerAddress, address _disputeManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_agreementStoreManagerAddressaddressagreement store manager address
_disputeManagerAddressaddressdispute manager address

changeDisputeManager

function changeDisputeManager(address _disputeManagerAddress) external

hashValues

function hashValues(uint256 _origHash, uint256[2] _buyer, uint256[2] _provider) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_origHashuint256is the hash of the key
_buyeruint256[2]buyer public key
_provideruint256[2]provider public key
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, uint256 _origHash, uint256[2] _buyer, uint256[2] _provider, uint256[2] _cipher, bytes _proof) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill key transfer

The key with hash _origHash is transferred to the _buyer from _provider.

NameTypeDescription
_agreementIdbytes32associated agreement
_origHashuint256is the hash of data to access
_buyeruint256[2]buyer public key
_provideruint256[2]provider public key
_cipheruint256[2]encrypted version of the key
_proofbytesSNARK proof that the cipher text can be decrypted by buyer to give the key with hash _origHash
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

ComputeExecutionCondition

Implementation of the Compute Execution Condition This condition is meant to be a signal in which triggers the execution of a compute service. The compute service is fully described in the associated DID document. The provider of the compute service will send this signal to its workers by fulfilling the condition where they are listening to the fulfilled event.

CONDITION_TYPE

bytes32 CONDITION_TYPE

computeExecutionStatus

mapping(bytes32 => mapping(address => bool)) computeExecutionStatus

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _computeConsumer, bytes32 _conditionId)

onlyDIDOwnerOrProvider

modifier onlyDIDOwnerOrProvider(bytes32 _did)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _agreementStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_agreementStoreManagerAddressaddressagreement store manager address

hashValues

function hashValues(bytes32 _did, address _computeConsumer) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32Decentralized Identifier (unique compute/asset resolver) describes the compute service
_computeConsumeraddressis the consumer's address
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _computeConsumer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill compute execution condition

only the compute provider can fulfill this condition. By fulfilling this condition the compute provider will trigger the execution of the offered job/compute. The compute service is described in a DID document.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32Decentralized Identifier (unique compute/asset resolver) describes the compute service
_computeConsumeraddressis the consumer's address
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

wasComputeTriggered

function wasComputeTriggered(bytes32 _did, address _computeConsumer) public view returns (bool)

wasComputeTriggered checks whether the compute is triggered or not.

NameTypeDescription
_didbytes32Decentralized Identifier (unique compute/asset resolver) describes the compute service
_computeConsumeraddressis the compute consumer's address
NameTypeDescription
[0]booltrue if the compute is triggered

Condition

_Implementation of the Condition

 Each condition has a validation function that returns either FULFILLED, 
ABORTED or UNFULFILLED. When a condition is successfully solved, we call
it FULFILLED. If a condition cannot be FULFILLED anymore due to a timeout
or other types of counter-proofs, the condition is ABORTED. UNFULFILLED
values imply that a condition has not been provably FULFILLED or ABORTED.
All initialized conditions start out as UNFULFILLED._

conditionStoreManager

contract ConditionStoreManager conditionStoreManager

generateId

function generateId(bytes32 _agreementId, bytes32 _valueHash) public view returns (bytes32)

generateId condition Id from the following parameters

NameTypeDescription
_agreementIdbytes32SEA agreement ID
_valueHashbytes32hash of all the condition input values

fulfill

function fulfill(bytes32 _id, enum ConditionStoreLibrary.ConditionState _newState) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfill set the condition state to Fulfill | Abort

NameTypeDescription
_idbytes32condition identifier
_newStateenum ConditionStoreLibrary.ConditionStatenew condition state (Fulfill/Abort)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatethe updated condition state

abortByTimeOut

function abortByTimeOut(bytes32 _id) external returns (enum ConditionStoreLibrary.ConditionState)

abortByTimeOut set condition state to Aborted if the condition is timed out

NameTypeDescription
_idbytes32condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatethe updated condition state

ConditionStoreLibrary

_Implementation of the Condition Store Library.

 Condition is a key component in the service execution agreement. 
This library holds the logic for creating and updating condition
Any Condition has only four state transitions starts with Uninitialized,
Unfulfilled, Fulfilled, and Aborted. Condition state transition goes only
forward from Unintialized -> Unfulfilled -> {Fulfilled || Aborted}_

ConditionState

enum ConditionState {
Uninitialized,
Unfulfilled,
Fulfilled,
Aborted
}

Condition

struct Condition {
address typeRef;
enum ConditionStoreLibrary.ConditionState state;
address createdBy;
address lastUpdatedBy;
uint256 blockNumberUpdated;
}

ConditionList

struct ConditionList {
mapping(bytes32 &#x3D;&gt; struct ConditionStoreLibrary.Condition) conditions;
mapping(bytes32 &#x3D;&gt; mapping(bytes32 &#x3D;&gt; bytes32)) map;
bytes32[] conditionIds;
}

create

function create(struct ConditionStoreLibrary.ConditionList _self, bytes32 _id, address _typeRef) internal

create new condition

check whether the condition exists, assigns condition type, condition state, last updated by, and update at (which is the current block number)

NameTypeDescription
_selfstruct ConditionStoreLibrary.ConditionListis the ConditionList storage pointer
_idbytes32valid condition identifier
_typeRefaddresscondition contract address

updateState

function updateState(struct ConditionStoreLibrary.ConditionList _self, bytes32 _id, enum ConditionStoreLibrary.ConditionState _newState) internal

updateState update the condition state

check whether the condition state transition is right, assign the new state, update last updated by and updated at.

NameTypeDescription
_selfstruct ConditionStoreLibrary.ConditionListis the ConditionList storage pointer
_idbytes32condition identifier
_newStateenum ConditionStoreLibrary.ConditionStatethe new state of the condition

updateKeyValue

function updateKeyValue(struct ConditionStoreLibrary.ConditionList _self, bytes32 _id, bytes32 _key, bytes32 _value) internal

ConditionStoreManager

_Implementation of the Condition Store Manager.

 Condition store manager is responsible for enforcing the 
the business logic behind creating/updating the condition state
based on the assigned role to each party. Only specific type of
contracts are allowed to call this contract, therefore there are
two types of roles, create role that in which is able to create conditions.
The second role is the update role, which is can update the condition state.
Also, it support delegating the roles to other contract(s)/account(s)._

PROXY_ROLE

bytes32 PROXY_ROLE

RoleType

enum RoleType {
Create,
Update
}

createRole

address createRole

conditionList

struct ConditionStoreLibrary.ConditionList conditionList

epochList

struct EpochLibrary.EpochList epochList

nvmConfigAddress

address nvmConfigAddress

ConditionCreated

event ConditionCreated(bytes32 _id, address _typeRef, address _who)

ConditionUpdated

event ConditionUpdated(bytes32 _id, address _typeRef, enum ConditionStoreLibrary.ConditionState _state, address _who)

onlyCreateRole

modifier onlyCreateRole()

onlyUpdateRole

modifier onlyUpdateRole(bytes32 _id)

onlyValidType

modifier onlyValidType(address typeRef)

initialize

function initialize(address _creator, address _owner, address _nvmConfigAddress) public

initialize ConditionStoreManager Initializer Initialize Ownable. Only on contract creation,

NameTypeDescription
_creatoraddressrefers to the creator of the contract
_owneraddressrefers to the owner of the contract
_nvmConfigAddressaddressrefers to the contract address of NeverminedConfig

getCreateRole

function getCreateRole() external view returns (address)

getCreateRole get the address of contract which has the create role

NameTypeDescription
[0]addresscreate condition role address

getNvmConfigAddress

function getNvmConfigAddress() external view returns (address)

getNvmConfigAddress get the address of the NeverminedConfig contract

NameTypeDescription
[0]addressNeverminedConfig contract address

setNvmConfigAddress

function setNvmConfigAddress(address _addr) external

delegateCreateRole

function delegateCreateRole(address delegatee) external

delegateCreateRole only owner can delegate the create condition role to a different address

NameTypeDescription
delegateeaddressdelegatee address

delegateUpdateRole

function delegateUpdateRole(bytes32 _id, address delegatee) external

delegateUpdateRole only owner can delegate the update role to a different address for specific condition Id which has the create role

NameTypeDescription
_idbytes32
delegateeaddressdelegatee address

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

createCondition

function createCondition(bytes32 _id, address _typeRef) external

createCondition only called by create role address the condition should use a valid condition contract address, valid time lock and timeout. Moreover, it enforce the condition state transition from Uninitialized to Unfulfilled.

NameTypeDescription
_idbytes32unique condition identifier
_typeRefaddresscondition contract address

createCondition2

function createCondition2(bytes32 _id, address _typeRef) external

createCondition

function createCondition(bytes32 _id, address _typeRef, uint256 _timeLock, uint256 _timeOut) public

createCondition only called by create role address the condition should use a valid condition contract address, valid time lock and timeout. Moreover, it enforce the condition state transition from Uninitialized to Unfulfilled.

NameTypeDescription
_idbytes32unique condition identifier
_typeRefaddresscondition contract address
_timeLockuint256start of the time window
_timeOutuint256end of the time window

updateConditionState

function updateConditionState(bytes32 _id, enum ConditionStoreLibrary.ConditionState _newState) external returns (enum ConditionStoreLibrary.ConditionState)

updateConditionState only called by update role address. It enforce the condition state transition to either Fulfill or Aborted state

NameTypeDescription
_idbytes32unique condition identifier
_newStateenum ConditionStoreLibrary.ConditionState
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatethe current condition state

updateConditionMapping

function updateConditionMapping(bytes32 _id, bytes32 _key, bytes32 _value) external

updateConditionMappingProxy

function updateConditionMappingProxy(bytes32 _id, bytes32 _key, bytes32 _value) external

getCondition

function getCondition(bytes32 _id) external view returns (address typeRef, enum ConditionStoreLibrary.ConditionState state, uint256 timeLock, uint256 timeOut, uint256 blockNumber)

getCondition

NameTypeDescription
typeRefaddressthe type reference
stateenum ConditionStoreLibrary.ConditionStatecondition state
timeLockuint256the time lock
timeOutuint256time out
blockNumberuint256block number

getConditionState

function getConditionState(bytes32 _id) external view virtual returns (enum ConditionStoreLibrary.ConditionState)

getConditionState

NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

getConditionTypeRef

function getConditionTypeRef(bytes32 _id) external view virtual returns (address)

getConditionTypeRef

NameTypeDescription
[0]addresscondition typeRef

getMappingValue

function getMappingValue(bytes32 _id, bytes32 _key) external view virtual returns (bytes32)

getConditionState

NameTypeDescription
[0]bytes32condition state

isConditionTimeLocked

function isConditionTimeLocked(bytes32 _id) public view returns (bool)

isConditionTimeLocked

NameTypeDescription
[0]boolwhether the condition is timedLock ended

isConditionTimedOut

function isConditionTimedOut(bytes32 _id) public view returns (bool)

isConditionTimedOut

NameTypeDescription
[0]boolwhether the condition is timed out

HashLockCondition

Implementation of the Hash Lock Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(uint256 _preimage) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_preimageuint256refers uint value of the hash pre-image.
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(string _preimage) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_preimagestringrefers string value of the hash pre-image.
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _preimage) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_preimagebytes32refers bytes32 value of the hash pre-image.
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, uint256 _preimage) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the condition by calling check the the hash and the pre-image uint value

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_preimageuint256
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfill

function fulfill(bytes32 _agreementId, string _preimage) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the condition by calling check the the hash and the pre-image string value

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_preimagestring
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfill

function fulfill(bytes32 _agreementId, bytes32 _preimage) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the condition by calling check the the hash and the pre-image bytes32 value

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_preimagebytes32
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

_fulfill

function _fulfill(bytes32 _generatedId) private returns (enum ConditionStoreLibrary.ConditionState)

_fulfill calls super fulfil method

NameTypeDescription
_generatedIdbytes32SEA agreement identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

ICondition

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes params) external payable

ILockPayment

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId, address _rewardAddress, address _tokenAddress, address[] _receivers, uint256[] _amounts)

hashValues

function hashValues(bytes32 _did, address _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_rewardAddressaddressthe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external payable returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires valid token transfer in order to lock the amount of tokens based on the SEA

NameTypeDescription
_agreementIdbytes32the agreement identifier
_didbytes32the asset decentralized identifier
_rewardAddressaddress payablethe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment.
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

LockPaymentCondition

Implementation of the Lock Payment Condition This condition allows to lock payment for multiple receivers taking into account the royalties to be paid to the original creators in a secondary market.

didRegistry

contract DIDRegistry didRegistry

nvmConfig

contract INVMConfig nvmConfig

CONDITION_TYPE

bytes32 CONDITION_TYPE

KEY_ASSET_RECEIVER

bytes32 KEY_ASSET_RECEIVER

PROXY_ROLE

bytes32 PROXY_ROLE

ALLOWED_EXTERNAL_CONTRACT_ROLE

bytes32 ALLOWED_EXTERNAL_CONTRACT_ROLE

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

grantExternalContractRole

function grantExternalContractRole(address _address) public

revokeExternalContractRole

function revokeExternalContractRole(address _address) public

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address

reinitialize

function reinitialize() external

Should be called when the contract has been upgraded.

hashValues

function hashValues(bytes32 _did, address _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_rewardAddressaddressthe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external payable returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires valid token transfer in order to lock the amount of tokens based on the SEA

NameTypeDescription
_agreementIdbytes32the agreement identifier
_didbytes32the asset decentralized identifier
_rewardAddressaddress payablethe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment.
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfillExternal

function fulfillExternal(bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _externalContract, bytes32 _remoteId, uint256[] _amounts, address[] _receivers) external payable returns (enum ConditionStoreLibrary.ConditionState)

fulfill lock condition using the funds locked in an external contract (auction, bonding curve, lottery, etc)

NameTypeDescription
_agreementIdbytes32the agreement identifier
_didbytes32the asset decentralized identifier
_rewardAddressaddress payablethe contract address where the reward is locked
_externalContractaddressthe address of the contract with the lock funds are locked
_remoteIdbytes32the id used to identify into the external contract
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

encodeParams

function encodeParams(bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) external pure returns (bytes)

fulfillInternal

function fulfillInternal(address _account, bytes32 _agreementId, bytes32 _did, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes params) external payable

_transferERC20Proxy

function _transferERC20Proxy(address _senderAddress, address _rewardAddress, address _tokenAddress, uint256 _amount) internal

_transferERC20Proxy transfer ERC20 tokens

Will throw if transfer fails

NameTypeDescription
_senderAddressaddressthe address to send the tokens from
_rewardAddressaddressthe address to receive the tokens
_tokenAddressaddressthe ERC20 contract address to use during the payment
_amountuint256token amount to be locked/released

_transferETH

function _transferETH(address payable _rewardAddress, uint256 _amount) internal

_transferETH transfer ETH

NameTypeDescription
_rewardAddressaddress payablethe address to receive the ETH
_amountuint256ETH amount to be locked/released

allowedExternalContract

modifier allowedExternalContract(address _externalContractAddress)

areMarketplaceFeesIncluded

function areMarketplaceFeesIncluded(uint256[] _amounts, address[] _receivers) internal view returns (bool)

DistributeNFTCollateralCondition

Implementation of a condition allowing to transfer a NFT to an account or another depending on the final state of a lock condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

aaveCreditVault

contract AaveCreditVault aaveCreditVault

_lockConditionAddress

address _lockConditionAddress

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _receiver, bytes32 _conditionId, address _contract)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _lockNFTConditionAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_lockNFTConditionAddressaddressLock NFT Condition address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _nftContractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_vaultAddressaddressThe contract address of the vault
_nftContractAddressaddressNFT contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _nftContractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_vaultAddressaddressThe contract address of the vault
_nftContractAddressaddressNFT contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

INFTAccess

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _documentId, address _grantee, bytes32 _conditionId)

hashValues

function hashValues(bytes32 _documentId, address _grantee, address _contractAddress) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee, address _contractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill NFT Access conditions

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

INFTHolder

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _address, bytes32 _conditionId, uint256 _amount)

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

INFTLock

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _lockAddress, bytes32 _conditionId, uint256 _amount, address _receiver, address _nftContractAddress)

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the NFTs locked
_nftContractAddressaddressIs the address of the NFT (ERC-721, ERC-1155) contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesMarked

function hashValuesMarked(bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) external pure returns (bytes32)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillMarked

function fulfillMarked(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

ITransferNFT

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _receiver, uint256 _amount, bytes32 _conditionId, address _contract)

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition, address _contract, bool _transfer) external pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
_contractaddress
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _contract, bool _transfer) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_contractaddress
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

getNFTDefaultAddress

function getNFTDefaultAddress() external view returns (address)

returns if the default NFT contract address

The default NFT contract address was given to the Transfer Condition during the contract initialization

NameTypeDescription
[0]addressthe NFT contract address used by default in the transfer condition

NFT721HolderCondition

Implementation of the Nft Holder Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

NFT721LockCondition

Implementation of the NFT Lock Condition for ERC-721 based NFTs

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesMarked

function hashValuesMarked(bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public pure returns (bytes32)

fulfillMarked

function fulfillMarked(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method lock a NFT into the _lockAddress.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens (1)
_receiveraddress
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-721) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

onERC721Received

function onERC721Received(address, address, uint256, bytes) public virtual returns (bytes4)

Always returns IERC721Receiver.onERC721Received.selector.

NFTAccessCondition

_Implementation of the Access Condition specific for NFTs

 NFT Access Condition is special condition used to give access 
to a specific NFT related to a DID._

CONDITION_TYPE

bytes32 CONDITION_TYPE

DocumentPermission

struct DocumentPermission {
bytes32 agreementIdDeprecated;
mapping(address &#x3D;&gt; bool) permission;
}

nftPermissions

mapping(bytes32 => struct NFTAccessCondition.DocumentPermission) nftPermissions

didRegistry

contract DIDRegistry didRegistry

onlyDIDOwnerOrProvider

modifier onlyDIDOwnerOrProvider(bytes32 _documentId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID registry address

hashValues

function hashValues(bytes32 _documentId, address _grantee) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _documentId, address _grantee, address _contractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill NFT Access condition

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _documentId, address _grantee, address _contractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill NFT Access condition

only DID owner or DID provider can call this method. Fulfill method sets the permissions for the granted consumer's address to true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys
_granteeaddressis the address of the granted user or the DID provider
_contractAddressaddressis the contract address of the NFT implementation (ERC-1155 or ERC-721)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

grantPermission

function grantPermission(address _grantee, bytes32 _documentId) public

grantPermission is called only by DID owner or provider

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID in which secret store will issue the decryption keys

checkPermissions

function checkPermissions(address _grantee, bytes32 _documentId) external view returns (bool permissionGranted)

checkPermissions is called to validate the permissions of user related to the NFT attached to an asset

NameTypeDescription
_granteeaddressis the address of the granted user or the DID provider
_documentIdbytes32refers to the DID
NameTypeDescription
permissionGrantedbooltrue if the access was granted

NFTHolderCondition

Implementation of the Nft Holder Condition

erc1155

contract ERC1155BurnableUpgradeable erc1155

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _ercAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_ercAddressaddressNevermined ERC-1155 address

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe address of the NFT holder
_amountuint256is the amount NFTs that need to be hold by the holder
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _holderAddress, uint256 _amount, address _contractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill requires a validation that holder has enough NFTs for a specific DID

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_didbytes32the Decentralized Identifier of the asset
_holderAddressaddressthe contract address where the reward is locked
_amountuint256is the amount of NFT to be hold
_contractAddressaddresscontract address holding the NFT (ERC-721) or the NFT Factory (ERC-1155)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

NFTLockCondition

Implementation of the NFT Lock Condition

erc1155

contract IERC1155Upgradeable erc1155

CONDITION_TYPE

bytes32 CONDITION_TYPE

ERC1155_ACCEPTED

bytes4 ERC1155_ACCEPTED

ERC1155_BATCH_ACCEPTED

bytes4 ERC1155_BATCH_ACCEPTED

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _ercAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_ercAddressaddressNevermined ERC-1155 address

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _did, address _lockAddress, uint256 _amount, address _nftContractAddress) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset with NFTs attached to lock
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_nftContractAddressaddressIs the address of the NFT (ERC-1155) contract to use
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesMarked

function hashValuesMarked(bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public pure returns (bytes32)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _nft) public returns (enum ConditionStoreLibrary.ConditionState)

fulfillMarked

function fulfillMarked(bytes32 _agreementId, bytes32 _did, address _lockAddress, uint256 _amount, address _receiver, address _nftContractAddress) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_lockAddressaddressthe contract address where the NFT will be locked
_amountuint256is the amount of the locked tokens
_receiveraddress
_nftContractAddressaddressIs the address of the NFT (ERC-1155) contract to use
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

onERC1155Received

function onERC1155Received(address, address, uint256, uint256, bytes) external pure returns (bytes4)

onERC1155BatchReceived

function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) external pure returns (bytes4)

supportsInterface

function supportsInterface(bytes4 interfaceId) external pure returns (bool)

_Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created.

This function call must use less than 30 000 gas._

TransferNFT721Condition

Implementation of condition allowing to transfer an NFT between the original owner and a receiver

CONDITION_TYPE

bytes32 CONDITION_TYPE

MARKET_ROLE

bytes32 MARKET_ROLE

erc721

contract NFT721Upgradeable erc721

_lockConditionAddress

address _lockConditionAddress

PROXY_ROLE

bytes32 PROXY_ROLE

didRegistry

contract DIDRegistry didRegistry

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress, address _ercAddress, address _lockNFTConditionAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address
_ercAddressaddressNevermined ERC-721 address
_lockNFTConditionAddressaddress

getNFTDefaultAddress

function getNFTDefaultAddress() external view returns (address)

returns if the default NFT contract address

The default NFT contract address was given to the Transfer Condition during the contract initialization

NameTypeDescription
[0]addressthe NFT contract address used by default in the transfer condition

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition, address _contract, bool _transfer) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
_contractaddressNFT contract to use
_transferbool
NameTypeDescription
[0]bytes32bytes32 hash of all these values

encodeParams

function encodeParams(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) external pure returns (bytes)

Encodes/serialize all the parameters received

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressthe NFT contract to use
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]bytesthe encoded parameters

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _contract, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_contractaddressNFT contract to use
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes _params) external payable

fulfill the transfer NFT condition by a proxy

Fulfill method transfer a certain amount of NFTs

NameTypeDescription
_accountaddressNFT Holder
_agreementIdbytes32agreement identifier
_paramsbytesencoded parameters

fulfillInternal

function fulfillInternal(address _account, bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _contract, bool _transfer, uint256 _expirationBlock) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, bool _transfer, address _nftContractAddress, uint256 _expirationBlock) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_transferboolif yes it does a transfer if false it mints the NFT
_nftContractAddressaddressthe address of the ERC-721 NFT contract
_expirationBlockuint256in which block the nft expires, if 0 it doesn't expire
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

TransferNFTCondition

Implementation of condition allowing to transfer an NFT between the original owner and a receiver

CONDITION_TYPE

bytes32 CONDITION_TYPE

MARKET_ROLE

bytes32 MARKET_ROLE

erc1155

contract NFTUpgradeable erc1155

didRegistry

contract DIDRegistry didRegistry

PROXY_ROLE

bytes32 PROXY_ROLE

grantProxyRole

function grantProxyRole(address _address) public

revokeProxyRole

function revokeProxyRole(address _address) public

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress, address _ercAddress, address _nftContractAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address
_ercAddressaddressNevermined ERC-1155 address
_nftContractAddressaddressMarket address

grantMarketRole

function grantMarketRole(address _nftContractAddress) public

revokeMarketRole

function revokeMarketRole(address _nftContractAddress) public

getNFTDefaultAddress

function getNFTDefaultAddress() external view returns (address)

returns if the default NFT contract address

The default NFT contract address was given to the Transfer Condition during the contract initialization

NameTypeDescription
[0]addressthe NFT contract address used by default in the transfer condition

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition) public view returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValues

function hashValues(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockCondition, address _nftContractAddress, bool _transfer) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddress
_nftReceiveraddressis the address of the granted user or the DID provider
_nftAmountuint256amount of NFTs to transfer
_lockConditionbytes32lock condition identifier
_nftContractAddressaddressNFT contract to use
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition) public returns (enum ConditionStoreLibrary.ConditionState)

encodeParams

function encodeParams(bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) external pure returns (bytes)

Encodes/serialize all the parameters received

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressthe NFT contract to use
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]bytesthe encoded parameters

fulfillProxy

function fulfillProxy(address _account, bytes32 _agreementId, bytes _params) external payable

fulfill the transfer NFT condition by a proxy

Fulfill method transfer a certain amount of NFTs

NameTypeDescription
_accountaddressNFT Holder
_agreementIdbytes32agreement identifier
_paramsbytesencoded parameters

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressNFT contract to use
_transferboolIndicates if the NFT will be transferred (true) or minted (false)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillInternal

function fulfillInternal(address _account, bytes32 _agreementId, bytes32 _did, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

fulfillForDelegate

function fulfillForDelegate(bytes32 _agreementId, bytes32 _did, address _nftHolder, address _nftReceiver, uint256 _nftAmount, bytes32 _lockPaymentCondition, address _nftContractAddress, bool _transfer) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer NFT condition

Fulfill method transfer a certain amount of NFTs to the _nftReceiver address in the DIDRegistry contract. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_nftHolderaddressis the address of the account to receive the NFT
_nftReceiveraddressis the address of the account to receive the NFT
_nftAmountuint256amount of NFTs to transfer
_lockPaymentConditionbytes32lock payment condition identifier
_nftContractAddressaddressthe address of the ERC-721 NFT contract
_transferboolif yes it does a transfer if false it mints the NFT
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

SignCondition

Implementation of the Sign Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _message, address _publicKey) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_messagebytes32the message to be signed
_publicKeyaddressthe public key of the signing address
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _message, address _publicKey, bytes _signature) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill validate the signed message and fulfill the condition

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_messagebytes32the message to be signed
_publicKeyaddressthe public key of the signing address
_signaturebytessignature of the signed message using the public key
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

ThresholdCondition

_Implementation of the Threshold Condition

 Threshold condition acts as a filter for a set of input condition(s) in which sends 
a signal whether to complete the flow execution or abort it. This type of conditions
works as intermediary conditions where they wire SEA conditions in order to support
more complex scenarios._

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32[] inputConditions, uint256 threshold) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
inputConditionsbytes32[]array of input conditions IDs
thresholduint256the required number of fulfilled input conditions
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32[] _inputConditions, uint256 threshold) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill threshold condition

the fulfill method check whether input conditions are fulfilled or not.

NameTypeDescription
_agreementIdbytes32agreement identifier
_inputConditionsbytes32[]array of input conditions IDs
thresholduint256the required number of fulfilled input conditions
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

canFulfill

function canFulfill(bytes32[] _inputConditions, uint256 threshold) private view returns (bool _fulfill)

canFulfill check if condition can be fulfilled

NameTypeDescription
_inputConditionsbytes32[]array of input conditions IDs
thresholduint256the required number of fulfilled input conditions
NameTypeDescription
_fulfillbooltrue if can fulfill

TransferDIDOwnershipCondition

Implementation of condition allowing to transfer the ownership between the original owner and a receiver

CONDITION_TYPE

bytes32 CONDITION_TYPE

didRegistry

contract DIDRegistry didRegistry

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, address _receiver, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address
_didRegistryAddressaddressDID Registry address

hashValues

function hashValues(bytes32 _did, address _receiver) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32refers to the DID in which secret store will issue the decryption keys
_receiveraddressis the address of the granted user or the DID provider
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _receiver) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill the transfer DID ownership condition

only DID owner or DID provider can call this method. Fulfill method transfer full ownership permissions to to _receiver address. When true then fulfill the condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32refers to the DID in which secret store will issue the decryption keys
_receiveraddressis the address of the granted user
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

WhitelistingCondition

Implementation of the Whitelisting Condition

CONDITION_TYPE

bytes32 CONDITION_TYPE

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(address _listAddress, bytes32 _item) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_listAddressaddresslist contract address
_itembytes32item in the list
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, address _listAddress, bytes32 _item) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill check whether address is whitelisted in order to fulfill the condition. This method will be called by any one in this whitelist.

NameTypeDescription
_agreementIdbytes32SEA agreement identifier
_listAddressaddresslist contract address
_itembytes32item in the list
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

AaveBorrowCondition

Implementation of the Aave Borrow Credit Condition

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _assetToBorrow, uint256 _amount, uint256 _interestRateMode) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToBorrowaddressthe address of the asset to borrow (i.e DAI)
_amountuint256the amount of the ERC-20 the assets to borrow (i.e 50 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _assetToBorrow, uint256 _amount, uint256 _interestRateMode) external returns (enum ConditionStoreLibrary.ConditionState)

It allows the borrower to borrow the asset deposited by the lender

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToBorrowaddressthe address of the asset to borrow (i.e DAI)
_amountuint256the amount of the ERC-20 the assets to borrow (i.e 50 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

AaveCollateralDepositCondition

Implementation of the Aave Collateral Deposit Condition This condition allows a Lender to deposit the collateral that into account the royalties to be paid to the original creators in a secondary market.

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _collateralAsset, uint256 _collateralAmount, address _delegatedAsset, uint256 _delegatedAmount, uint256 _interestRateMode) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the ERC-20 that will be used as collateral (i.e WETH)
_collateralAmountuint256the amount of the ERC-20 that will be used as collateral (i.e 10 WETH)
_delegatedAssetaddressthe address of the ERC-20 that will be delegated to the borrower (i.e DAI)
_delegatedAmountuint256the amount of the ERC-20 that will be delegated to the borrower (i.e 500 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _collateralAsset, uint256 _collateralAmount, address _delegatedAsset, uint256 _delegatedAmount, uint256 _interestRateMode) external payable returns (enum ConditionStoreLibrary.ConditionState)

It fulfills the condition if the collateral can be deposited into the vault

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the ERC-20 that will be used as collateral (i.e WETH)
_collateralAmountuint256the amount of the ERC-20 that will be used as collateral (i.e 10 WETH)
_delegatedAssetaddressthe address of the ERC-20 that will be delegated to the borrower (i.e DAI)
_delegatedAmountuint256the amount of the ERC-20 that will be delegated to the borrower (i.e 500 DAI)
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

AaveCollateralWithdrawCondition

Implementation of the Collateral Withdraw Condition This condition allows to credit delegator withdraw the collateral and fees after the agreement expiration

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _collateralAsset) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the asset used as collateral (i.e DAI)
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _collateralAsset) external payable returns (enum ConditionStoreLibrary.ConditionState)

It allows the borrower to repay the loan

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressAddress of the vault
_collateralAssetaddressthe address of the asset used as collateral (i.e DAI)
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

AaveCreditVault

lendingPool

contract ILendingPool lendingPool

dataProvider

contract IProtocolDataProvider dataProvider

weth

contract IWETHGateway weth

addressProvider

contract ILendingPoolAddressesProvider addressProvider

priceOracle

contract IPriceOracleGetter priceOracle

borrowedAsset

address borrowedAsset

borrowedAmount

uint256 borrowedAmount

nvmFee

uint256 nvmFee

agreementFee

uint256 agreementFee

FEE_BASE

uint256 FEE_BASE

treasuryAddress

address treasuryAddress

borrower

address borrower

lender

address lender

repayConditionId

bytes32 repayConditionId

nftId

uint256 nftId

nftAddress

address nftAddress

BORROWER_ROLE

bytes32 BORROWER_ROLE

LENDER_ROLE

bytes32 LENDER_ROLE

CONDITION_ROLE

bytes32 CONDITION_ROLE

initialize

function initialize(address _lendingPool, address _dataProvider, address _weth, uint256 _nvmFee, uint256 _agreementFee, address _treasuryAddress, address _borrower, address _lender, address[] _conditions) public

Vault constructor, creates a unique vault for each agreement

NameTypeDescription
_lendingPooladdressAave lending pool address
_dataProvideraddressAave data provider address
_wethaddressWETH address
_nvmFeeuint256Nevermined fee that will apply to this agreeement
_agreementFeeuint256Agreement fee that lender will receive on agreement maturity
_treasuryAddressaddressAddress of nevermined contract to store fees
_borroweraddress
_lenderaddress
_conditionsaddress[]

isLender

function isLender(address _address) public view returns (bool)

isBorrower

function isBorrower(address _address) public view returns (bool)

deposit

function deposit(address _collateralAsset, uint256 _amount) public payable

Deposit function. Receives the funds from the delegator and deposits the funds in the Aave contracts

NameTypeDescription
_collateralAssetaddresscollateral asset that will be deposit on Aave
_amountuint256Amount of collateral to deposit

approveBorrower

function approveBorrower(address _borrower, uint256 _amount, address _asset, uint256 _interestRateMode) public

Appproves delegatee to borrow funds from Aave on behalf of delegator

NameTypeDescription
_borroweraddressdelegatee that will borrow the funds
_amountuint256Amount of funds to delegate
_assetaddressAsset to delegate the borrow
_interestRateModeuint256interest rate type stable 1, variable 2

delegatedAmount

function delegatedAmount(address _borrower, address _asset, uint256 _interestRateMode) public view returns (uint256)

Return the actual delegated amount for the borrower in the specific asset

NameTypeDescription
_borroweraddressThe borrower of the funds (i.e. delgatee)
_assetaddressThe asset they are allowed to borrow
_interestRateModeuint256interest rate type stable 1, variable 2

borrow

function borrow(address _assetToBorrow, uint256 _amount, address _delgatee, uint256 _interestRateMode) public

Borrower can call this function to borrow the delegated funds

NameTypeDescription
_assetToBorrowaddressThe asset they are allowed to borrow
_amountuint256Amount to borrow
_delgateeaddressAddress where the funds will be transfered
_interestRateModeuint256interest rate type stable 1, variable 2

repay

function repay(address _asset, uint256 _interestRateMode, bytes32 _repayConditionId) public

Repay an uncollaterised loan

NameTypeDescription
_assetaddressThe asset to be repaid
_interestRateModeuint256interest rate type stable 1, variable 2
_repayConditionIdbytes32identifier of the condition id working as lock for other vault methods

setRepayConditionId

function setRepayConditionId(bytes32 _repayConditionId) public

getBorrowedAmount

function getBorrowedAmount() public view returns (uint256)

Returns the borrowed amount from the delegatee on this agreement

getAssetPrice

function getAssetPrice(address _asset) public view returns (uint256)

Returns the priceof the asset in the Aave oracles

NameTypeDescription
_assetaddressThe asset to get the actual price

getCreditAssetDebt

function getCreditAssetDebt() public view returns (uint256)

Returns the total debt of the credit in the Aave protocol expressed in token units

getActualCreditDebt

function getActualCreditDebt() public view returns (uint256)

Returns the total debt of the credit in the Aave protocol expressed in ETH units

getTotalActualDebt

function getTotalActualDebt() public view returns (uint256)

Returns the total actual debt of the agreement credit + fees in token units

withdrawCollateral

function withdrawCollateral(address _asset, address _delegator) public

Withdraw all of a collateral as the underlying asset, if no outstanding loans delegated

NameTypeDescription
_assetaddressThe underlying asset to withdraw
_delegatoraddressDelegator address that deposited the collateral

transferNFT

function transferNFT(uint256 _tokenId, address _receiver) public

Transfer a NFT (ERC-721) locked into the vault to a receiver address

NameTypeDescription
_tokenIduint256the token id
_receiveraddressthe receiver adddress

_transferERC20

function _transferERC20(address _collateralAsset, uint256 _amount) internal

Transfers the ERC20 token deposited to the Aave contracts

NameTypeDescription
_collateralAssetaddresscollateral asset that will be deposit on Aave
_amountuint256Amount of collateral to deposit

onERC721Received

function onERC721Received(address, address, uint256 _tokenId, bytes) public virtual returns (bytes4)

Handle the receipt of an NFT

_The ERC721 smart contract calls this function on the recipient after a {IERC721-safeTransferFrom}. This function MUST return the function selector, otherwise the caller will revert the transaction.

Note: the ERC721 contract address is always the message sender. (param not used): operator The address which called safeTransferFrom function (param not used): from The address which previously owned the token_

NameTypeDescription
address
address
_tokenIduint256The NFT identifier which is being transferred (param not used): data Additional data with no specified format
bytes
NameTypeDescription
[0]bytes4bytes4 bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))

AaveRepayCondition

Implementation of the Aave Repay Condition This condition allows to a borrower to repay a credit as part of a credit template

aaveCreditVault

contract AaveCreditVault aaveCreditVault

CONDITION_TYPE

bytes32 CONDITION_TYPE

Fulfilled

event Fulfilled(bytes32 _agreementId, bytes32 _did, bytes32 _conditionId)

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

this function is called only once during the contract initialization.

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, address _vaultAddress, address _assetToRepay, uint256 _amountToRepay, uint256 _interestRateMode) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToRepayaddressthe address of the asset to repay (i.e DAI)
_amountToRepayuint256Amount to repay
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, address _vaultAddress, address _assetToRepay, uint256 _amountToRepay, uint256 _interestRateMode) external returns (enum ConditionStoreLibrary.ConditionState)

It allows the borrower to repay the loan

NameTypeDescription
_agreementIdbytes32the identifier of the agreement
_didbytes32the DID of the asset
_vaultAddressaddressthe address of vault locking the deposited collateral and the asset
_assetToRepayaddressthe address of the asset to repay (i.e DAI)
_amountToRepayuint256Amount to repay
_interestRateModeuint256interest rate type stable 1, variable 2
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStateConditionStoreLibrary.ConditionState the state of the condition (Fulfilled if everything went good)

EscrowPaymentCondition

_Implementation of the Escrow Payment Condition

 The Escrow payment is reward condition in which only 
can release reward if lock and release conditions
are fulfilled._

CONDITION_TYPE

bytes32 CONDITION_TYPE

USED_PAYMENT_ID

bytes32 USED_PAYMENT_ID

Fulfilled

event Fulfilled(bytes32 _agreementId, address _tokenAddress, address[] _receivers, bytes32 _conditionId, uint256[] _amounts)

Received

event Received(address _from, uint256 _value)

receive

receive() external payable

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValuesMulti

function hashValuesMulti(bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32asset decentralized identifier
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

encodeParams

function encodeParams(bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes)

hashValues

function hashValues(bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32 _releaseCondition) public pure returns (bytes32)

hashValuesLockPayment

function hashValuesLockPayment(bytes32 _did, address _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public pure returns (bytes32)

hashValuesLockPayment generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_rewardAddressaddressthe contract address where the reward is locked
_tokenAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfillMulti

function fulfillMulti(bytes32 _agreementId, bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public returns (enum ConditionStoreLibrary.ConditionState)

fulfill escrow reward condition

fulfill method checks whether the lock and release conditions are fulfilled in order to release/refund the reward to receiver/sender respectively.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

Args

struct Args {
bytes32 _agreementId;
bytes32 _did;
uint256[] _amounts;
address[] _receivers;
address _returnAddress;
address _lockPaymentAddress;
address _tokenAddress;
bytes32 _lockCondition;
bytes32[] _releaseConditions;
}

fulfillKludge

function fulfillKludge(struct EscrowPaymentCondition.Args a) internal returns (enum ConditionStoreLibrary.ConditionState)

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32 _releaseCondition) external returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfillERC20

function _transferAndFulfillERC20(bytes32 _id, address _tokenAddress, address[] _receivers, uint256[] _amounts) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ERC20 tokens and fulfill the condition

NameTypeDescription
_idbytes32condition identifier
_tokenAddressaddressthe ERC20 contract address to use during the payment
_receiversaddress[]receiver's address
_amountsuint256[]token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

_transferAndFulfillETH

function _transferAndFulfillETH(bytes32 _id, address[] _receivers, uint256[] _amounts) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ETH and fulfill the condition

NameTypeDescription
_idbytes32condition identifier
_receiversaddress[]receiver's address
_amountsuint256[]token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

INFTEscrow

Common interface for ERC-721 and ERC-1155

Fulfilled

event Fulfilled(bytes32 _agreementId, address _tokenAddress, bytes32 _did, address _receivers, bytes32 _conditionId, uint256 _amounts)

NFT721EscrowPaymentCondition

_Implementation of the Escrow Payment Condition

 The Escrow payment is reward condition in which only 
can release reward if lock and release conditions
are fulfilled._

CONDITION_TYPE

bytes32 CONDITION_TYPE

Received

event Received(address _from, uint256 _value)

receive

receive() external payable

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, uint256 _amounts, address _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32asset decentralized identifier
_amountsuint256token amounts to be locked/released
_receiversaddressreceiver's addresses
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesLockPayment

function hashValuesLockPayment(bytes32 _did, address _lockAddress, address _nftContractAddress, uint256 _amount, address _receiver) public pure returns (bytes32)

hashValuesLockPayment generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_lockAddressaddressthe contract address where the reward is locked
_nftContractAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, uint256 _amount, address _receiver, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill escrow reward condition

fulfill method checks whether the lock and release conditions are fulfilled in order to release/refund the reward to receiver/sender respectively.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

Args

struct Args {
bytes32 _agreementId;
bytes32 _did;
uint256 _amount;
address _receiver;
address _returnAddress;
address _lockPaymentAddress;
address _tokenAddress;
bytes32 _lockCondition;
bytes32[] _releaseConditions;
}

fulfillKludge

function fulfillKludge(struct NFT721EscrowPaymentCondition.Args a) internal returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfillNFT

function _transferAndFulfillNFT(bytes32 _agreementId, bytes32 _id, bytes32 _did, address _tokenAddress, address _receiver, uint256 _amount) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ERC20 tokens and fulfill the condition

NameTypeDescription
_agreementIdbytes32
_idbytes32condition identifier
_didbytes32
_tokenAddressaddressthe ERC20 contract address to use during the payment
_receiveraddressreceiver's address
_amountuint256token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

onERC721Received

function onERC721Received(address, address, uint256, bytes) public virtual returns (bytes4)

NFTEscrowPaymentCondition

_Implementation of the Escrow Payment Condition

 The Escrow payment is reward condition in which only 
can release reward if lock and release conditions
are fulfilled._

CONDITION_TYPE

bytes32 CONDITION_TYPE

LOCK_CONDITION_TYPE

bytes32 LOCK_CONDITION_TYPE

Received

event Received(address _from, uint256 _value)

receive

receive() external payable

initialize

function initialize(address _owner, address _conditionStoreManagerAddress) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address
_conditionStoreManagerAddressaddresscondition store manager address

hashValues

function hashValues(bytes32 _did, uint256 _amounts, address _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public pure returns (bytes32)

hashValues generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32asset decentralized identifier
_amountsuint256token amounts to be locked/released
_receiversaddressreceiver's addresses
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]bytes32bytes32 hash of all these values

hashValuesLockPayment

function hashValuesLockPayment(bytes32 _did, address _lockAddress, address _nftContractAddress, uint256 _amount, address _receiver) public pure returns (bytes32)

hashValuesLockPayment generates the hash of condition inputs with the following parameters

NameTypeDescription
_didbytes32the asset decentralized identifier
_lockAddressaddressthe contract address where the reward is locked
_nftContractAddressaddressthe ERC20 contract address to use during the lock payment. If the address is 0x0 means we won't use a ERC20 but ETH for payment
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's addresses
NameTypeDescription
[0]bytes32bytes32 hash of all these values

fulfill

function fulfill(bytes32 _agreementId, bytes32 _did, uint256 _amount, address _receiver, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) external returns (enum ConditionStoreLibrary.ConditionState)

fulfill escrow reward condition

fulfill method checks whether the lock and release conditions are fulfilled in order to release/refund the reward to receiver/sender respectively.

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountuint256token amounts to be locked/released
_receiveraddressreceiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

Args

struct Args {
bytes32 _agreementId;
bytes32 _did;
uint256 _amount;
address _receiver;
address _returnAddress;
address _lockPaymentAddress;
address _tokenAddress;
bytes32 _lockCondition;
bytes32[] _releaseConditions;
}

fulfillKludge

function fulfillKludge(struct NFTEscrowPaymentCondition.Args a) internal returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfillNFT

function _transferAndFulfillNFT(bytes32 _agreementId, bytes32 _id, bytes32 _did, address _tokenAddress, address _receiver, uint256 _amount) private returns (enum ConditionStoreLibrary.ConditionState)

_transferAndFulfill transfer ERC20 tokens and fulfill the condition

NameTypeDescription
_agreementIdbytes32
_idbytes32condition identifier
_didbytes32
_tokenAddressaddressthe ERC20 contract address to use during the payment
_receiveraddressreceiver's address
_amountuint256token amount to be locked/released
NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state (Fulfilled/Aborted)

ERC1155_ACCEPTED

bytes4 ERC1155_ACCEPTED

ERC1155_BATCH_ACCEPTED

bytes4 ERC1155_BATCH_ACCEPTED

onERC1155Received

function onERC1155Received(address, address, uint256, uint256, bytes) external pure returns (bytes4)

onERC1155BatchReceived

function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) external pure returns (bytes4)

supportsInterface

function supportsInterface(bytes4 interfaceId) external pure returns (bool)

_Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created.

This function call must use less than 30 000 gas._

Reward

_Implementation of the Reward.

 Generic reward condition_

INVMConfig

GOVERNOR_ROLE

bytes32 GOVERNOR_ROLE

NeverminedConfigChange

event NeverminedConfigChange(address _whoChanged, bytes32 _parameter)

Event that is emitted when a parameter is changed

NameTypeDescription
_whoChangedaddressthe address of the governor changing the parameter
_parameterbytes32the hash of the name of the parameter changed

initialize

function initialize(address _owner, address _governor) external virtual

Used to initialize the contract during delegator constructor

NameTypeDescription
_owneraddressThe owner of the contract
_governoraddressThe address to be granted with the GOVERNOR_ROLE

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver) external virtual

The governor can update the Nevermined Marketplace fees

NameTypeDescription
_marketplaceFeeuint256new marketplace fee
_feeReceiveraddressThe address receiving the fee

isGovernor

function isGovernor(address _address) external view virtual returns (bool)

Indicates if an address is a having the GOVERNOR role

NameTypeDescription
_addressaddressThe address to validate
NameTypeDescription
[0]booltrue if is a governor

getMarketplaceFee

function getMarketplaceFee() external view virtual returns (uint256)

Returns the marketplace fee

NameTypeDescription
[0]uint256the marketplace fee

getFeeReceiver

function getFeeReceiver() external view virtual returns (address)

Returns the receiver address of the marketplace fee

NameTypeDescription
[0]addressthe receiver address

NeverminedConfig

marketplaceFee

uint256 marketplaceFee

feeReceiver

address feeReceiver

initialize

function initialize(address _owner, address _governor) public

Used to initialize the contract during delegator constructor

NameTypeDescription
_owneraddressThe owner of the contract
_governoraddressThe address to be granted with the GOVERNOR_ROLE

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver) external virtual

The governor can update the Nevermined Marketplace fees

NameTypeDescription
_marketplaceFeeuint256new marketplace fee
_feeReceiveraddressThe address receiving the fee

setGovernor

function setGovernor(address _address) external

isGovernor

function isGovernor(address _address) external view returns (bool)

Indicates if an address is a having the GOVERNOR role

NameTypeDescription
_addressaddressThe address to validate
NameTypeDescription
[0]booltrue if is a governor

getMarketplaceFee

function getMarketplaceFee() external view returns (uint256)

Returns the marketplace fee

NameTypeDescription
[0]uint256the marketplace fee

getFeeReceiver

function getFeeReceiver() external view returns (address)

Returns the receiver address of the marketplace fee

NameTypeDescription
[0]addressthe receiver address

onlyGovernor

modifier onlyGovernor(address _address)

IERC20

totalSupply

function totalSupply() external view returns (uint256)

Returns the amount of tokens in existence.

balanceOf

function balanceOf(address account) external view returns (uint256)

Returns the amount of tokens owned by account.

transfer

function transfer(address recipient, uint256 amount) external returns (bool)

_Moves amount tokens from the caller's account to recipient.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event._

allowance

function allowance(address owner, address spender) external view returns (uint256)

_Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner through {transferFrom}. This is zero by default.

This value changes when {approve} or {transferFrom} are called._

approve

function approve(address spender, uint256 amount) external returns (bool)

_Sets amount as the allowance of spender over the caller's tokens.

Returns a boolean value indicating whether the operation succeeded.

IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

Emits an {Approval} event._

transferFrom

function transferFrom(address sender, address recipient, uint256 amount) external returns (bool)

_Moves amount tokens from sender to recipient using the allowance mechanism. amount is then deducted from the caller's allowance.

Returns a boolean value indicating whether the operation succeeded.

Emits a {Transfer} event._

Transfer

event Transfer(address from, address to, uint256 value)

_Emitted when value tokens are moved from one account (from) to another (to).

Note that value may be zero._

Approval

event Approval(address owner, address spender, uint256 value)

Emitted when the allowance of a spender for an owner is set by a call to {approve}. value is the new allowance.

IPriceOracleGetter

Interface for the Aave price oracle.

getAssetPrice

function getAssetPrice(address asset) external view returns (uint256)

returns the asset price in ETH

NameTypeDescription
assetaddressthe address of the asset
NameTypeDescription
[0]uint256the ETH price of the asset

IProtocolDataProvider

TokenData

struct TokenData {
string symbol;
address tokenAddress;
}

ADDRESSES_PROVIDER

function ADDRESSES_PROVIDER() external view returns (contract ILendingPoolAddressesProvider)

getAllReservesTokens

function getAllReservesTokens() external view returns (struct IProtocolDataProvider.TokenData[])

getAllATokens

function getAllATokens() external view returns (struct IProtocolDataProvider.TokenData[])

getReserveConfigurationData

function getReserveConfigurationData(address asset) external view returns (uint256 decimals, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive, bool isFrozen)

getReserveData

function getReserveData(address asset) external view returns (uint256 availableLiquidity, uint256 totalStableDebt, uint256 totalVariableDebt, uint256 liquidityRate, uint256 variableBorrowRate, uint256 stableBorrowRate, uint256 averageStableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex, uint40 lastUpdateTimestamp)

getUserReserveData

function getUserReserveData(address asset, address user) external view returns (uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled)

getReserveTokensAddresses

function getReserveTokensAddresses(address asset) external view returns (address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress)

ILendingPoolAddressesProvider

MarketIdSet

event MarketIdSet(string newMarketId)

LendingPoolUpdated

event LendingPoolUpdated(address newAddress)

ConfigurationAdminUpdated

event ConfigurationAdminUpdated(address newAddress)

EmergencyAdminUpdated

event EmergencyAdminUpdated(address newAddress)

LendingPoolConfiguratorUpdated

event LendingPoolConfiguratorUpdated(address newAddress)

LendingPoolCollateralManagerUpdated

event LendingPoolCollateralManagerUpdated(address newAddress)

PriceOracleUpdated

event PriceOracleUpdated(address newAddress)

LendingRateOracleUpdated

event LendingRateOracleUpdated(address newAddress)

ProxyCreated

event ProxyCreated(bytes32 id, address newAddress)

AddressSet

event AddressSet(bytes32 id, address newAddress, bool hasProxy)

getMarketId

function getMarketId() external view returns (string)

setMarketId

function setMarketId(string marketId) external

setAddress

function setAddress(bytes32 id, address newAddress) external

setAddressAsProxy

function setAddressAsProxy(bytes32 id, address impl) external

getAddress

function getAddress(bytes32 id) external view returns (address)

getLendingPool

function getLendingPool() external view returns (address)

setLendingPoolImpl

function setLendingPoolImpl(address pool) external

getLendingPoolConfigurator

function getLendingPoolConfigurator() external view returns (address)

setLendingPoolConfiguratorImpl

function setLendingPoolConfiguratorImpl(address configurator) external

getLendingPoolCollateralManager

function getLendingPoolCollateralManager() external view returns (address)

setLendingPoolCollateralManager

function setLendingPoolCollateralManager(address manager) external

getPoolAdmin

function getPoolAdmin() external view returns (address)

setPoolAdmin

function setPoolAdmin(address admin) external

getEmergencyAdmin

function getEmergencyAdmin() external view returns (address)

setEmergencyAdmin

function setEmergencyAdmin(address admin) external

getPriceOracle

function getPriceOracle() external view returns (address)

setPriceOracle

function setPriceOracle(address priceOracle) external

getLendingRateOracle

function getLendingRateOracle() external view returns (address)

setLendingRateOracle

function setLendingRateOracle(address lendingRateOracle) external

ILendingPool

Deposit

event Deposit(address reserve, address user, address onBehalfOf, uint256 amount, uint16 referral)

Emitted on deposit()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address initiating the deposit
onBehalfOfaddressThe beneficiary of the deposit, receiving the aTokens
amountuint256The amount deposited
referraluint16The referral code used

Withdraw

event Withdraw(address reserve, address user, address to, uint256 amount)

Emitted on withdraw()

NameTypeDescription
reserveaddressThe address of the underlyng asset being withdrawn
useraddressThe address initiating the withdrawal, owner of aTokens
toaddressAddress that will receive the underlying
amountuint256The amount to be withdrawn

Borrow

event Borrow(address reserve, address user, address onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 referral)

Emitted on borrow() and flashLoan() when debt needs to be opened

NameTypeDescription
reserveaddressThe address of the underlying asset being borrowed
useraddressThe address of the user initiating the borrow(), receiving the funds on borrow() or just initiator of the transaction on flashLoan()
onBehalfOfaddressThe address that will be getting the debt
amountuint256The amount borrowed out
borrowRateModeuint256The rate mode: 1 for Stable, 2 for Variable
borrowRateuint256The numeric rate at which the user has borrowed
referraluint16The referral code used

Repay

event Repay(address reserve, address user, address repayer, uint256 amount)

Emitted on repay()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe beneficiary of the repayment, getting his debt reduced
repayeraddressThe address of the user initiating the repay(), providing the funds
amountuint256The amount repaid

Swap

event Swap(address reserve, address user, uint256 rateMode)

Emitted on swapBorrowRateMode()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user swapping his rate mode
rateModeuint256The rate mode that the user wants to swap to

ReserveUsedAsCollateralEnabled

event ReserveUsedAsCollateralEnabled(address reserve, address user)

Emitted on setUserUseReserveAsCollateral()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user enabling the usage as collateral

ReserveUsedAsCollateralDisabled

event ReserveUsedAsCollateralDisabled(address reserve, address user)

Emitted on setUserUseReserveAsCollateral()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user enabling the usage as collateral

RebalanceStableBorrowRate

event RebalanceStableBorrowRate(address reserve, address user)

Emitted on rebalanceStableBorrowRate()

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
useraddressThe address of the user for which the rebalance has been executed

FlashLoan

event FlashLoan(address target, address initiator, address asset, uint256 amount, uint256 premium, uint16 referralCode)

Emitted on flashLoan()

NameTypeDescription
targetaddressThe address of the flash loan receiver contract
initiatoraddressThe address initiating the flash loan
assetaddressThe address of the asset being flash borrowed
amountuint256The amount flash borrowed
premiumuint256The fee flash borrowed
referralCodeuint16The referral code used

Paused

event Paused()

Emitted when the pause is triggered.

Unpaused

event Unpaused()

Emitted when the pause is lifted.

LiquidationCall

event LiquidationCall(address collateralAsset, address debtAsset, address user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken)

Emitted when a borrower is liquidated. This event is emitted by the LendingPool via LendingPoolCollateral manager using a DELEGATECALL This allows to have the events in the generated ABI for LendingPool.

NameTypeDescription
collateralAssetaddressThe address of the underlying asset used as collateral, to receive as result of the liquidation
debtAssetaddressThe address of the underlying borrowed asset to be repaid with the liquidation
useraddressThe address of the borrower getting liquidated
debtToCoveruint256The debt amount of borrowed asset the liquidator wants to cover
liquidatedCollateralAmountuint256The amount of collateral received by the liiquidator
liquidatoraddressThe address of the liquidator
receiveATokenbooltrue if the liquidators wants to receive the collateral aTokens, false if he wants to receive the underlying collateral asset directly

ReserveDataUpdated

event ReserveDataUpdated(address reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex)

Emitted when the state of a reserve is updated. NOTE: This event is actually declared in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it gets added to the LendingPool ABI

NameTypeDescription
reserveaddressThe address of the underlying asset of the reserve
liquidityRateuint256The new liquidity rate
stableBorrowRateuint256The new stable borrow rate
variableBorrowRateuint256The new variable borrow rate
liquidityIndexuint256The new liquidity index
variableBorrowIndexuint256The new variable borrow index

deposit

function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external

_Deposits an amount of underlying asset into the reserve, receiving in return overlying aTokens.

  • E.g. User deposits 100 USDC and gets in return 100 aUSDC_
NameTypeDescription
assetaddressThe address of the underlying asset to deposit
amountuint256The amount to be deposited
onBehalfOfaddressThe address that will receive the aTokens, same as msg.sender if the user wants to receive them on his own wallet, or a different address if the beneficiary of aTokens is a different wallet
referralCodeuint16Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man

withdraw

function withdraw(address asset, uint256 amount, address to) external returns (uint256)

Withdraws an amount of underlying asset from the reserve, burning the equivalent aTokens owned E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC

NameTypeDescription
assetaddressThe address of the underlying asset to withdraw
amountuint256The underlying amount to be withdrawn - Send the value type(uint256).max in order to withdraw the whole aToken balance
toaddressAddress that will receive the underlying, same as msg.sender if the user wants to receive it on his own wallet, or a different address if the beneficiary is a different wallet
NameTypeDescription
[0]uint256The final amount withdrawn

borrow

function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf) external

_Allows users to borrow a specific amount of the reserve underlying asset, provided that the borrower already deposited enough collateral, or he was given enough allowance by a credit delegator on the corresponding debt token (StableDebtToken or VariableDebtToken)

  • E.g. User borrows 100 USDC passing as onBehalfOf his own address, receiving the 100 USDC in his wallet and 100 stable/variable debt tokens, depending on the interestRateMode_
NameTypeDescription
assetaddressThe address of the underlying asset to borrow
amountuint256The amount to be borrowed
interestRateModeuint256The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable
referralCodeuint16Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man
onBehalfOfaddressAddress of the user who will receive the debt. Should be the address of the borrower itself calling the function if he wants to borrow against his own collateral, or the address of the credit delegator if he has been given credit delegation allowance

repay

function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf) external returns (uint256)

Repays a borrowed amount on a specific reserve, burning the equivalent debt tokens owned

  • E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the onBehalfOf address
NameTypeDescription
assetaddressThe address of the borrowed underlying asset previously borrowed
amountuint256The amount to repay - Send the value type(uint256).max in order to repay the whole debt for asset on the specific debtMode
rateModeuint256The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable
onBehalfOfaddressAddress of the user who will get his debt reduced/removed. Should be the address of the user calling the function if he wants to reduce/remove his own debt, or the address of any other other borrower whose debt should be removed
NameTypeDescription
[0]uint256The final amount repaid

swapBorrowRateMode

function swapBorrowRateMode(address asset, uint256 rateMode) external

Allows a borrower to swap his debt between stable and variable mode, or viceversa

NameTypeDescription
assetaddressThe address of the underlying asset borrowed
rateModeuint256The rate mode that the user wants to swap to

rebalanceStableBorrowRate

function rebalanceStableBorrowRate(address asset, address user) external

_Rebalances the stable interest rate of a user to the current stable rate defined on the reserve.

  • Users can be rebalanced if the following conditions are satisfied:
    1. Usage ratio is above 95%
    2. the current deposit APY is below REBALANCEUP_THRESHOLD * maxVariableBorrowRate, which means that too much has been borrowed at a stable rate and depositors are not earning enough
NameTypeDescription
assetaddressThe address of the underlying asset borrowed
useraddressThe address of the user to be rebalanced

setUserUseReserveAsCollateral

function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external

Allows depositors to enable/disable a specific deposited asset as collateral

NameTypeDescription
assetaddressThe address of the underlying asset deposited
useAsCollateralbooltrue if the user wants to use the deposit as collateral, false otherwise

liquidationCall

function liquidationCall(address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken) external

_Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1

  • The caller (liquidator) covers debtToCover amount of debt of the user getting liquidated, and receives a proportionally amount of the collateralAsset plus a bonus to cover market risk_
NameTypeDescription
collateralAssetaddressThe address of the underlying asset used as collateral, to receive as result of the liquidation
debtAssetaddressThe address of the underlying borrowed asset to be repaid with the liquidation
useraddressThe address of the borrower getting liquidated
debtToCoveruint256The debt amount of borrowed asset the liquidator wants to cover
receiveATokenbooltrue if the liquidators wants to receive the collateral aTokens, false if he wants to receive the underlying collateral asset directly

flashLoan

function flashLoan(address receiverAddress, address[] assets, uint256[] amounts, uint256[] modes, address onBehalfOf, bytes params, uint16 referralCode) external

Allows smartcontracts to access the liquidity of the pool within one transaction, as long as the amount taken plus a fee is returned. IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. For further details please visit https://developers.aave.com

NameTypeDescription
receiverAddressaddressThe address of the contract receiving the funds, implementing the IFlashLoanReceiver interface
assetsaddress[]The addresses of the assets being flash-borrowed
amountsuint256[]The amounts amounts being flash-borrowed
modesuint256[]Types of the debt to open if the flash loan is not returned: 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the onBehalfOf address 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the onBehalfOf address
onBehalfOfaddressThe address that will receive the debt in the case of using on modes 1 or 2
paramsbytesVariadic packed params to pass to the receiver as extra information
referralCodeuint16Code used to register the integrator originating the operation, for potential rewards. 0 if the action is executed directly by the user, without any middle-man

getUserAccountData

function getUserAccountData(address user) external view returns (uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)

Returns the user account data across all the reserves

NameTypeDescription
useraddressThe address of the user
NameTypeDescription
totalCollateralETHuint256the total collateral in ETH of the user
totalDebtETHuint256the total debt in ETH of the user
availableBorrowsETHuint256the borrowing power left of the user
currentLiquidationThresholduint256the liquidation threshold of the user
ltvuint256the loan to value of the user
healthFactoruint256the current health factor of the user

initReserve

function initReserve(address reserve, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress) external

setReserveInterestRateStrategyAddress

function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external

setConfiguration

function setConfiguration(address reserve, uint256 configuration) external

getConfiguration

function getConfiguration(address asset) external view returns (struct DataTypes.ReserveConfigurationMap)

Returns the configuration of the reserve

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]struct DataTypes.ReserveConfigurationMapThe configuration of the reserve

getUserConfiguration

function getUserConfiguration(address user) external view returns (struct DataTypes.UserConfigurationMap)

Returns the configuration of the user across all the reserves

NameTypeDescription
useraddressThe user address
NameTypeDescription
[0]struct DataTypes.UserConfigurationMapThe configuration of the user

getReserveNormalizedIncome

function getReserveNormalizedIncome(address asset) external view returns (uint256)

Returns the normalized income normalized income of the reserve

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]uint256The reserve's normalized income

getReserveNormalizedVariableDebt

function getReserveNormalizedVariableDebt(address asset) external view returns (uint256)

Returns the normalized variable debt per unit of asset

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]uint256The reserve normalized variable debt

getReserveData

function getReserveData(address asset) external view returns (struct DataTypes.ReserveData)

Returns the state and configuration of the reserve

NameTypeDescription
assetaddressThe address of the underlying asset of the reserve
NameTypeDescription
[0]struct DataTypes.ReserveDataThe state of the reserve

finalizeTransfer

function finalizeTransfer(address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore) external

getReservesList

function getReservesList() external view returns (address[])

getAddressesProvider

function getAddressesProvider() external view returns (contract ILendingPoolAddressesProvider)

setPause

function setPause(bool val) external

paused

function paused() external view returns (bool)

IStableDebtToken

Mint

event Mint(address user, address onBehalfOf, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 newRate, uint256 avgStableRate, uint256 newTotalSupply)

Emitted when new stable debt is minted

NameTypeDescription
useraddressThe address of the user who triggered the minting
onBehalfOfaddressThe recipient of stable debt tokens
amountuint256The amount minted
currentBalanceuint256The current balance of the user
balanceIncreaseuint256The increase in balance since the last action of the user
newRateuint256The rate of the debt after the minting
avgStableRateuint256The new average stable rate after the minting
newTotalSupplyuint256The new total supply of the stable debt token after the action

Burn

event Burn(address user, uint256 amount, uint256 currentBalance, uint256 balanceIncrease, uint256 avgStableRate, uint256 newTotalSupply)

Emitted when new stable debt is burned

NameTypeDescription
useraddressThe address of the user
amountuint256The amount being burned
currentBalanceuint256The current balance of the user
balanceIncreaseuint256The the increase in balance since the last action of the user
avgStableRateuint256The new average stable rate after the burning
newTotalSupplyuint256The new total supply of the stable debt token after the action

approveDelegation

function approveDelegation(address delegatee, uint256 amount) external

delegates borrowing power to a user on the specific debt token

NameTypeDescription
delegateeaddressthe address receiving the delegated borrowing power
amountuint256the maximum amount being delegated. Delegation will still respect the liquidation constraints (even if delegated, a delegatee cannot force a delegator HF to go below 1)

borrowAllowance

function borrowAllowance(address fromUser, address toUser) external view returns (uint256)

returns the borrow allowance of the user

NameTypeDescription
fromUseraddressThe user to giving allowance
toUseraddressThe user to give allowance to
NameTypeDescription
[0]uint256the current allowance of toUser

mint

function mint(address user, address onBehalfOf, uint256 amount, uint256 rate) external returns (bool)

_Mints debt token to the onBehalfOf address.

  • The resulting rate is the weighted average between the rate of the new debt and the rate of the previous debt_
NameTypeDescription
useraddressThe address receiving the borrowed underlying, being the delegatee in case of credit delegate, or same as onBehalfOf otherwise
onBehalfOfaddressThe address receiving the debt tokens
amountuint256The amount of debt tokens to mint
rateuint256The rate of the debt being minted

burn

function burn(address user, uint256 amount) external

_Burns debt of user

  • The resulting rate is the weighted average between the rate of the new debt and the rate of the previous debt_
NameTypeDescription
useraddressThe address of the user getting his debt burned
amountuint256The amount of debt tokens getting burned

getAverageStableRate

function getAverageStableRate() external view returns (uint256)

Returns the average rate of all the stable rate loans.

NameTypeDescription
[0]uint256The average stable rate

getUserStableRate

function getUserStableRate(address user) external view returns (uint256)

Returns the stable rate of the user debt

NameTypeDescription
[0]uint256The stable rate of the user

getUserLastUpdated

function getUserLastUpdated(address user) external view returns (uint40)

Returns the timestamp of the last update of the user

NameTypeDescription
[0]uint40The timestamp

getSupplyData

function getSupplyData() external view returns (uint256, uint256, uint256, uint40)

Returns the principal, the total supply and the average stable rate

getTotalSupplyLastUpdated

function getTotalSupplyLastUpdated() external view returns (uint40)

Returns the timestamp of the last update of the total supply

NameTypeDescription
[0]uint40The timestamp

getTotalSupplyAndAvgRate

function getTotalSupplyAndAvgRate() external view returns (uint256, uint256)

Returns the total supply and the average stable rate

principalBalanceOf

function principalBalanceOf(address user) external view returns (uint256)

Returns the principal debt balance of the user

NameTypeDescription
[0]uint256The debt balance of the user since the last burn/mint action

IDynamicPricing

DynamicPricingState

enum DynamicPricingState {
NotStarted,
Finished,
InProgress,
Aborted
}

getPricingType

function getPricingType() external view returns (bytes32)

getPrice

function getPrice(bytes32 did) external view returns (uint256)

getTokenAddress

function getTokenAddress(bytes32 did) external view returns (address)

getStatus

function getStatus(bytes32 did) external view returns (enum IDynamicPricing.DynamicPricingState, uint256, address)

canBePurchased

function canBePurchased(bytes32 did) external view returns (bool)

withdraw

function withdraw(bytes32 did, address withdrawAddress) external returns (bool)

IList

has

function has(bytes32 value) external view returns (bool)

has

function has(bytes32 value, bytes32 id) external view returns (bool)

IRoyaltyScheme

check

function check(bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) external view returns (bool)

check that royalties are correct

NameTypeDescription
_didbytes32compute royalties for this DID
_amountsuint256[]amounts in payment
_receiversaddress[]receivers of payments
_tokenAddressaddresspayment token. zero address means native token (ether)

ISecretStore

checkPermissions

function checkPermissions(address user, bytes32 documentKeyId) external view returns (bool permissionGranted)

checkPermissions is called by Parity secret store

ISecretStorePermission

grantPermission

function grantPermission(address user, bytes32 documentKeyId) external

grantPermission is called only by documentKeyId Owner or provider

renouncePermission

function renouncePermission(address user, bytes32 documentKeyId) external

renouncePermission is called only by documentKeyId Owner or provider

IWETHGateway

depositETH

function depositETH(address lendingPool, address onBehalfOf, uint16 referralCode) external payable

withdrawETH

function withdrawETH(address lendingPool, uint256 amount, address to) external

repayETH

function repayETH(address lendingPool, uint256 amount, uint256 rateMode, address onBehalfOf) external payable

borrowETH

function borrowETH(address lendingPool, uint256 amount, uint256 interesRateMode, uint16 referralCode) external

DataTypes

ReserveData

struct ReserveData {
struct DataTypes.ReserveConfigurationMap configuration;
uint128 liquidityIndex;
uint128 variableBorrowIndex;
uint128 currentLiquidityRate;
uint128 currentVariableBorrowRate;
uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
address interestRateStrategyAddress;
uint8 id;
}

ReserveConfigurationMap

struct ReserveConfigurationMap {
uint256 data;
}

UserConfigurationMap

struct UserConfigurationMap {
uint256 data;
}

InterestRateMode

enum InterestRateMode {
NONE,
STABLE,
VARIABLE
}

SafeMath

add

function add(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the addition of two unsigned integers, reverting on overflow.

Counterpart to Solidity's + operator.

Requirements:

  • Addition cannot overflow._

sub

function sub(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative).

Counterpart to Solidity's - operator.

Requirements:

  • Subtraction cannot overflow._

sub

function sub(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)

_Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative).

Counterpart to Solidity's - operator.

Requirements:

  • Subtraction cannot overflow._

mul

function mul(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the multiplication of two unsigned integers, reverting on overflow.

Counterpart to Solidity's * operator.

Requirements:

  • Multiplication cannot overflow._

div

function div(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero.

Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

div

function div(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)

_Returns the integer division of two unsigned integers. Reverts with custom message on division by zero. The result is rounded towards zero.

Counterpart to Solidity's / operator. Note: this function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

mod

function mod(uint256 a, uint256 b) internal pure returns (uint256)

_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero.

Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

mod

function mod(uint256 a, uint256 b, string errorMessage) internal pure returns (uint256)

_Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts with custom message when dividing by zero.

Counterpart to Solidity's % operator. This function uses a revert opcode (which leaves remaining gas untouched) while Solidity uses an invalid opcode to revert (consuming all remaining gas).

Requirements:

  • The divisor cannot be zero._

Address

isContract

function isContract(address account) internal view returns (bool)

_Returns true if account is a contract.

[IMPORTANT]

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract.

Among others, isContract will return false for the following types of addresses:

  • an externally-owned account
  • a contract in construction
  • an address where a contract will be created
  • an address where a contract lived, but was destroyed ====_

sendValue

function sendValue(address payable recipient, uint256 amount) internal

_Replacement for Solidity's transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors.

https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. {sendValue} removes this limitation.

https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].

IMPORTANT: because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using {ReentrancyGuard} or the https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]._

SafeERC20

Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a using SafeERC20 for IERC20; statement to your contract, which allows you to call the safe operations as token.safeTransfer(...), etc.

safeTransfer

function safeTransfer(contract IERC20 token, address to, uint256 value) internal

safeTransferFrom

function safeTransferFrom(contract IERC20 token, address from, address to, uint256 value) internal

safeApprove

function safeApprove(contract IERC20 token, address spender, uint256 value) internal

callOptionalReturn

function callOptionalReturn(contract IERC20 token, bytes data) private

CloneFactory

createClone

function createClone(address target) internal returns (address result)

isClone

function isClone(address target, address query) internal view returns (bool result)

EpochLibrary

Implementation of Epoch Library. For an arbitrary Epoch, this library manages the life cycle of an Epoch. Usually this library is used for handling the time window between conditions in an agreement.

Epoch

struct Epoch {
uint256 timeLock;
uint256 timeOut;
uint256 blockNumber;
}

EpochList

struct EpochList {
mapping(bytes32 &#x3D;&gt; struct EpochLibrary.Epoch) epochs;
bytes32[] epochIds;
}

create

function create(struct EpochLibrary.EpochList _self, bytes32 _id, uint256 _timeLock, uint256 _timeOut) internal

create creates new Epoch

NameTypeDescription
_selfstruct EpochLibrary.EpochListis the Epoch storage pointer
_idbytes32
_timeLockuint256value in block count (can not fulfill before)
_timeOutuint256value in block count (can not fulfill after)

isTimedOut

function isTimedOut(struct EpochLibrary.EpochList _self, bytes32 _id) external view returns (bool)

isTimedOut means you cannot fulfill after

NameTypeDescription
_selfstruct EpochLibrary.EpochListis the Epoch storage pointer
_idbytes32
NameTypeDescription
[0]booltrue if the current block number is gt timeOut

isTimeLocked

function isTimeLocked(struct EpochLibrary.EpochList _self, bytes32 _id) external view returns (bool)

isTimeLocked means you cannot fulfill before

NameTypeDescription
_selfstruct EpochLibrary.EpochListis the Epoch storage pointer
_idbytes32
NameTypeDescription
[0]booltrue if the current block number is gt timeLock

getEpochTimeOut

function getEpochTimeOut(struct EpochLibrary.Epoch _self) public view returns (uint256)

getEpochTimeOut

NameTypeDescription
_selfstruct EpochLibrary.Epochis the Epoch storage pointer

getEpochTimeLock

function getEpochTimeLock(struct EpochLibrary.Epoch _self) public view returns (uint256)

getEpochTimeLock

NameTypeDescription
_selfstruct EpochLibrary.Epochis the Epoch storage pointer

HashListLibrary

Implementation of the basic functionality of list of hash values. This library allows other contracts to build and maintain lists and also preserves the privacy of the data by accepting only hashed content (bytes32 based data type)

List

struct List {
address _owner;
bytes32[] values;
mapping(bytes32 &#x3D;&gt; uint256) indices;
}

onlyListOwner

modifier onlyListOwner(struct HashListLibrary.List _self)

add

function add(struct HashListLibrary.List _self, bytes32 value) public returns (bool)

add index an element then add it to a list

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is a bytes32 value
NameTypeDescription
[0]booltrue if value is added successfully

add

function add(struct HashListLibrary.List _self, bytes32[] values) public returns (bool)

put an array of elements without indexing this meant to save gas in case of large arrays

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuesbytes32[]is an array of elements value
NameTypeDescription
[0]booltrue if values are added successfully

update

function update(struct HashListLibrary.List _self, bytes32 oldValue, bytes32 newValue) public returns (bool)

update the value with a new value and maintain indices

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
oldValuebytes32is an element value in a list
newValuebytes32new value
NameTypeDescription
[0]booltrue if value is updated successfully

remove

function remove(struct HashListLibrary.List _self, bytes32 value) public returns (bool)

remove value from a list, updates indices, and list size

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is an element value in a list
NameTypeDescription
[0]booltrue if value is removed successfully

get

function get(struct HashListLibrary.List _self, uint256 __index) public view returns (bytes32)

has value by index

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
__indexuint256is where is value is stored in the list
NameTypeDescription
[0]bytes32the value if exists

index

function index(struct HashListLibrary.List _self, uint256 from, uint256 to) public returns (bool)

index is used to map each element value to its index on the list

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
fromuint256index is where to 'from' indexing in the list
touint256index is where to stop indexing
NameTypeDescription
[0]booltrue if the sub list is indexed

setOwner

function setOwner(struct HashListLibrary.List _self, address _owner) public

setOwner set list owner param _owner owner address

indexOf

function indexOf(struct HashListLibrary.List _self, bytes32 value) public view returns (uint256)

indexOf gets the index of a value in a list

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is element value in list
NameTypeDescription
[0]uint256value index in list

isIndexed

function isIndexed(struct HashListLibrary.List _self) public view returns (bool)

isIndexed checks if the list is indexed

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]booltrue if the list is indexed

all

function all(struct HashListLibrary.List _self) public view returns (bytes32[])

all returns all list elements

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]bytes32[]all list elements

has

function has(struct HashListLibrary.List _self, bytes32 value) public view returns (bool)

size returns the list size

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
valuebytes32is element value in list
NameTypeDescription
[0]booltrue if the value exists

size

function size(struct HashListLibrary.List _self) public view returns (uint256)

size gets the list size

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]uint256total length of the list

ownedBy

function ownedBy(struct HashListLibrary.List _self) public view returns (address)

ownedBy gets the list owner

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
NameTypeDescription
[0]addresslist owner

_index

function _index(struct HashListLibrary.List _self, uint256 from, uint256 to) private returns (bool)

_index assign index to the list elements

NameTypeDescription
_selfstruct HashListLibrary.Listis a pointer to list in the storage
fromuint256is the starting index id
touint256is the ending index id

AbstractAuction

AUCTION_MANAGER_ROLE

bytes32 AUCTION_MANAGER_ROLE

NVM_AGREEMENT_ROLE

bytes32 NVM_AGREEMENT_ROLE

Auction

struct Auction {
bytes32 did;
enum IDynamicPricing.DynamicPricingState state;
address creator;
uint256 blockNumberCreated;
uint256 floor;
uint256 starts;
uint256 ends;
uint256 price;
address tokenAddress;
address whoCanClaim;
string hash;
}

auctions

mapping(bytes32 => struct AbstractAuction.Auction) auctions

auctionBids

mapping(bytes32 => mapping(address => uint256)) auctionBids

AuctionCreated

event AuctionCreated(bytes32 auctionId, bytes32 did, address creator, uint256 blockNumberCreated, uint256 floor, uint256 starts, uint256 ends, address tokenAddress)

AuctionChangedState

event AuctionChangedState(bytes32 auctionId, address who, enum IDynamicPricing.DynamicPricingState previousState, enum IDynamicPricing.DynamicPricingState newState)

AuctionBidReceived

event AuctionBidReceived(bytes32 auctionId, address bidder, address tokenAddress, uint256 amount)

AuctionWithdrawal

event AuctionWithdrawal(bytes32 auctionId, address receiver, address tokenAddress, uint256 amount)

receive

receive() external payable

abortAuction

function abortAuction(bytes32 _auctionId) external virtual

withdraw

function withdraw(bytes32 _auctionId, address _withdrawAddress) external virtual returns (bool)

getPricingType

function getPricingType() external pure virtual returns (bytes32)

getPrice

function getPrice(bytes32 _auctionId) external view returns (uint256)

getTokenAddress

function getTokenAddress(bytes32 _auctionId) external view returns (address)

getStatus

function getStatus(bytes32 _auctionId) external view returns (enum IDynamicPricing.DynamicPricingState state, uint256 price, address whoCanClaim)

canBePurchased

function canBePurchased(bytes32 _auctionId) external view virtual returns (bool)

addNVMAgreementRole

function addNVMAgreementRole(address account) public

onlyCreator

modifier onlyCreator(bytes32 _auctionId)

onlyCreatorOrAdmin

modifier onlyCreatorOrAdmin(bytes32 _auctionId)

onlyNotCreator

modifier onlyNotCreator(bytes32 _auctionId)

onlyAfterStart

modifier onlyAfterStart(bytes32 _auctionId)

onlyBeforeStarts

modifier onlyBeforeStarts(bytes32 _auctionId)

onlyBeforeEnd

modifier onlyBeforeEnd(bytes32 _auctionId)

onlyNotAbortedOrFinished

modifier onlyNotAbortedOrFinished(bytes32 _auctionId)

onlyAbortedOrFinished

modifier onlyAbortedOrFinished(bytes32 _auctionId)

onlyNotAborted

modifier onlyNotAborted(bytes32 _auctionId)

onlyFinishedOrAborted

modifier onlyFinishedOrAborted(bytes32 _auctionId)

DutchAuction

initialize

function initialize(address _owner) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address

create

function create(bytes32 _auctionId, bytes32 _did, uint256 _startPrice, uint256 _starts, uint256 _ends, address _tokenAddress, string _hash) external virtual

It creates a new Auction given some setup parameters

NameTypeDescription
_auctionIdbytes32unique auction identifier
_didbytes32reference to the asset part of the auction
_startPriceuint256start price (and max) for the auction
_startsuint256block number when the auction starts
_endsuint256block number of when the auction ends
_tokenAddressaddresstoken address to use for the auction. If address(0) means native token
_hashstringipfs hash referring to the auction metadata

placeNativeTokenBid

function placeNativeTokenBid(bytes32 _auctionId) external payable virtual

placeERC20Bid

function placeERC20Bid(bytes32 _auctionId, uint256 _bidAmount) external virtual

withdraw

function withdraw(bytes32 _auctionId, address _withdrawAddress) external virtual returns (bool)

getPricingType

function getPricingType() external pure returns (bytes32)

EnglishAuction

initialize

function initialize(address _owner) external

initialize init the contract with the following parameters

NameTypeDescription
_owneraddresscontract's owner account address

create

function create(bytes32 _auctionId, bytes32 _did, uint256 _floor, uint256 _starts, uint256 _ends, address _tokenAddress, string _hash) external virtual

It creates a new Auction given some setup parameters

NameTypeDescription
_auctionIdbytes32unique auction identifier
_didbytes32reference to the asset part of the auction
_flooruint256floor price
_startsuint256block number when the auction starts
_endsuint256block number of when the auction ends
_tokenAddressaddresstoken address to use for the auction. If address(0) means native token
_hashstringipfs hash referring to the auction metadata

placeNativeTokenBid

function placeNativeTokenBid(bytes32 _auctionId) external payable virtual

placeERC20Bid

function placeERC20Bid(bytes32 _auctionId, uint256 _bidAmount) external virtual

getPricingType

function getPricingType() external pure returns (bytes32)

DIDFactory

Implementation of the DID Registry.

didRegisterList

struct DIDRegistryLibrary.DIDRegisterList didRegisterList

state storage for the DID registry

didPermissions

mapping(bytes32 => mapping(address => bool)) didPermissions

manager

address manager

onlyDIDOwner

modifier onlyDIDOwner(bytes32 _did)

onlyManager

modifier onlyManager()

onlyOwnerProviderOrDelegated

modifier onlyOwnerProviderOrDelegated(bytes32 _did)

onlyValidAttributes

modifier onlyValidAttributes(string _attributes)

nftIsInitialized

modifier nftIsInitialized(bytes32 _did)

nft721IsInitialized

modifier nft721IsInitialized(bytes32 _did)

DIDAttributeRegistered

event DIDAttributeRegistered(bytes32 _did, address _owner, bytes32 _checksum, string _value, address _lastUpdatedBy, uint256 _blockNumberUpdated)

DID Events

DIDProviderRemoved

event DIDProviderRemoved(bytes32 _did, address _provider, bool state)

DIDProviderAdded

event DIDProviderAdded(bytes32 _did, address _provider)

DIDOwnershipTransferred

event DIDOwnershipTransferred(bytes32 _did, address _previousOwner, address _newOwner)

DIDPermissionGranted

event DIDPermissionGranted(bytes32 _did, address _owner, address _grantee)

DIDPermissionRevoked

event DIDPermissionRevoked(bytes32 _did, address _owner, address _grantee)

DIDProvenanceDelegateRemoved

event DIDProvenanceDelegateRemoved(bytes32 _did, address _delegate, bool state)

DIDProvenanceDelegateAdded

event DIDProvenanceDelegateAdded(bytes32 _did, address _delegate)

setManager

function setManager(address _addr) external

Sets the manager role. Should be the TransferCondition contract address

registerAttribute

function registerAttribute(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url) public virtual

Register DID attributes.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]
_urlstringrefers to the attribute value, limited to 2048 bytes.

registerDID

function registerDID(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, bytes32 _activityId, string _attributes) public virtual

Register DID attributes.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID). The final DID will be calculated with the creator address using the hashDID function
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes

hashDID

function hashDID(bytes32 _didSeed, address _creator) public pure returns (bytes32)

It generates a DID using as seed a bytes32 and the address of the DID creator

NameTypeDescription
_didSeedbytes32refers to DID Seed used as base to generate the final DID
_creatoraddressaddress of the creator of the DID
NameTypeDescription
[0]bytes32the new DID created

areRoyaltiesValid

function areRoyaltiesValid(bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) public view returns (bool)

areRoyaltiesValid checks if for a given DID and rewards distribution, this allocate the
original creator royalties properly

NameTypeDescription
_didbytes32refers to decentralized identifier (a byte32 length ID)
_amountsuint256[]refers to the amounts to reward
_receiversaddress[]refers to the receivers of rewards
_tokenAddressaddress
NameTypeDescription
[0]booltrue if the rewards distribution respect the original creator royalties

wasGeneratedBy

function wasGeneratedBy(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) internal returns (bool)

used

function used(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, bytes _signatureUsing, string _attributes) public returns (bool success)

wasDerivedFrom

function wasDerivedFrom(bytes32 _provId, bytes32 _newEntityDid, bytes32 _usedEntityDid, address _agentId, bytes32 _activityId, string _attributes) public returns (bool success)

wasAssociatedWith

function wasAssociatedWith(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) public returns (bool success)

actedOnBehalf

function actedOnBehalf(bytes32 _provId, bytes32 _did, address _delegateAgentId, address _responsibleAgentId, bytes32 _activityId, bytes _signatureDelegate, string _attributes) public returns (bool success)

Implements the W3C PROV Delegation action Each party involved in this method (_delegateAgentId & _responsibleAgentId) must provide a valid signature. The content to sign is a representation of the footprint of the event (_did + _delegateAgentId + _responsibleAgentId + _activityId)

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity
_delegateAgentIdaddressrefers to address acting on behalf of the provenance record
_responsibleAgentIdaddressrefers to address responsible of the provenance record
_activityIdbytes32refers to activity
_signatureDelegatebytesrefers to the digital signature provided by the did delegate.
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

addDIDProvider

function addDIDProvider(bytes32 _did, address _provider) external

addDIDProvider add new DID provider.

it adds new DID provider to the providers list. A provider is any entity that can serve the registered asset

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_provideraddressprovider's address.

removeDIDProvider

function removeDIDProvider(bytes32 _did, address _provider) external

removeDIDProvider delete an existing DID provider.

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_provideraddressprovider's address.

addDIDProvenanceDelegate

function addDIDProvenanceDelegate(bytes32 _did, address _delegate) public

addDIDProvenanceDelegate add new DID provenance delegate.

it adds new DID provenance delegate to the delegates list. A delegate is any entity that interact with the provenance entries of one DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_delegateaddressdelegates's address.

removeDIDProvenanceDelegate

function removeDIDProvenanceDelegate(bytes32 _did, address _delegate) external

removeDIDProvenanceDelegate delete an existing DID delegate.

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_delegateaddressdelegate's address.

transferDIDOwnership

function transferDIDOwnership(bytes32 _did, address _newOwner) external

transferDIDOwnership transfer DID ownership

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_newOwneraddressnew owner address

transferDIDOwnershipManaged

function transferDIDOwnershipManaged(address _sender, bytes32 _did, address _newOwner) external

transferDIDOwnershipManaged transfer DID ownership

NameTypeDescription
_senderaddress
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_newOwneraddressnew owner address

_transferDIDOwnership

function _transferDIDOwnership(address _sender, bytes32 _did, address _newOwner) internal

grantPermission

function grantPermission(bytes32 _did, address _grantee) external

grantPermission grants access permission to grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

revokePermission

function revokePermission(bytes32 _did, address _grantee) external

revokePermission revokes access permission from grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

getPermission

function getPermission(bytes32 _did, address _grantee) external view returns (bool)

getPermission gets access permission of a grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress
NameTypeDescription
[0]booltrue if grantee has access permission to a DID

isDIDProvider

function isDIDProvider(bytes32 _did, address _provider) public view returns (bool)

isDIDProvider check whether a given DID provider exists

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_provideraddressprovider's address.

isDIDProviderOrOwner

function isDIDProviderOrOwner(bytes32 _did, address _provider) public view returns (bool)

getDIDRegister

function getDIDRegister(bytes32 _did) public view returns (address owner, bytes32 lastChecksum, string url, address lastUpdatedBy, uint256 blockNumberUpdated, address[] providers, uint256 nftSupply, uint256 mintCap, uint256 royalties)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
owneraddressthe did owner
lastChecksumbytes32last checksum
urlstringURL to the DID metadata
lastUpdatedByaddresswho was the last updating the DID
blockNumberUpdateduint256In which block was the DID updated
providersaddress[]the list of providers
nftSupplyuint256the supply of nfts
mintCapuint256the maximum number of nfts that can be minted
royaltiesuint256the royalties amount

getDIDSupply

function getDIDSupply(bytes32 _did) public view returns (uint256 nftSupply, uint256 mintCap)

getBlockNumberUpdated

function getBlockNumberUpdated(bytes32 _did) public view returns (uint256 blockNumberUpdated)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
blockNumberUpdateduint256last modified (update) block number of a DID.

getDIDOwner

function getDIDOwner(bytes32 _did) public view returns (address didOwner)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
didOwneraddressthe address of the DID owner.

getDIDRoyaltyRecipient

function getDIDRoyaltyRecipient(bytes32 _did) public view returns (address)

getDIDRoyaltyScheme

function getDIDRoyaltyScheme(bytes32 _did) public view returns (address)

getDIDCreator

function getDIDCreator(bytes32 _did) public view returns (address)

_grantPermission

function _grantPermission(bytes32 _did, address _grantee) internal

_grantPermission grants access permission to grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

_revokePermission

function _revokePermission(bytes32 _did, address _grantee) internal

_revokePermission revokes access permission from grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress

_getPermission

function _getPermission(bytes32 _did, address _grantee) internal view returns (bool)

_getPermission gets access permission of a grantee

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID)
_granteeaddressaddress
NameTypeDescription
[0]booltrue if grantee has access permission to a DID

getProvenanceEntry

function getProvenanceEntry(bytes32 _provId) public view returns (bytes32 did, bytes32 relatedDid, address agentId, bytes32 activityId, address agentInvolvedId, uint8 method, address createdBy, uint256 blockNumberUpdated, bytes signature)

Fetch the complete provenance entry attributes

NameTypeDescription
_provIdbytes32refers to the provenance identifier
NameTypeDescription
didbytes32to what DID refers this entry
relatedDidbytes32DID related with the entry
agentIdaddressthe agent identifier
activityIdbytes32referring to the id of the activity
agentInvolvedIdaddressagent involved with the action
methoduint8the w3c provenance method
createdByaddresswho is creating this entry
blockNumberUpdateduint256in which block was updated
signaturebytesdigital signature

isDIDOwner

function isDIDOwner(address _address, bytes32 _did) public view returns (bool)

isDIDOwner check whether a given address is owner for a DID

NameTypeDescription
_addressaddressuser address.
_didbytes32refers to decentralized identifier (a bytes32 length ID).

isOwnerProviderOrDelegate

function isOwnerProviderOrDelegate(bytes32 _did) public view returns (bool)

isOwnerProviderOrDelegate check whether msg.sender is owner, provider or delegate for a DID given

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
[0]boolboolean true if yes

isProvenanceDelegate

function isProvenanceDelegate(bytes32 _did, address _delegate) public view returns (bool)

isProvenanceDelegate check whether a given DID delegate exists

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_delegateaddressdelegate's address.
NameTypeDescription
[0]boolboolean true if yes

getProvenanceOwner

function getProvenanceOwner(bytes32 _did) public view returns (address provenanceOwner)
NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
NameTypeDescription
provenanceOwneraddressthe address of the Provenance owner.

DIDRegistry

Implementation of a Mintable DID Registry.

erc1155

contract NFTUpgradeable erc1155

erc721

contract NFT721Upgradeable erc721

royaltiesCheckers

mapping(address => bool) royaltiesCheckers

initialize

function initialize(address _owner, address _erc1155, address _erc721) public

DIDRegistry Initializer Initialize Ownable. Only on contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract.
_erc1155address
_erc721address

registerRoyaltiesChecker

function registerRoyaltiesChecker(address _addr) public

DIDRoyaltiesAdded

event DIDRoyaltiesAdded(bytes32 did, address addr)

DIDRoyaltyRecipientChanged

event DIDRoyaltyRecipientChanged(bytes32 did, address addr)

setDIDRoyalties

function setDIDRoyalties(bytes32 _did, address _royalties) public

setDIDRoyaltyRecipient

function setDIDRoyaltyRecipient(bytes32 _did, address _recipient) public

registerMintableDID

function registerMintableDID(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, uint256 _cap, uint8 _royalties, bool _mint, bytes32 _activityId, string _nftMetadata) public

Register a Mintable DID using NFTs based in the ERC-1155 standard.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif true it mints the ERC-1155 NFTs attached to the asset
_activityIdbytes32refers to activity
_nftMetadatastringrefers to the url providing the NFT Metadata

registerMintableDID721

function registerMintableDID721(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, uint8 _royalties, bool _mint, bytes32 _activityId, string _nftMetadata) public

Register a Mintable DID using NFTs based in the ERC-721 standard.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif true it mints the ERC-1155 NFTs attached to the asset
_activityIdbytes32refers to activity
_nftMetadatastringrefers to the url providing the NFT Metadata

registerMintableDID

function registerMintableDID(bytes32 _didSeed, bytes32 _checksum, address[] _providers, string _url, uint256 _cap, uint8 _royalties, bytes32 _activityId, string _nftMetadata) public

Register a Mintable DID.

The first attribute of a DID registered sets the DID owner. Subsequent updates record _checksum and update info.

NameTypeDescription
_didSeedbytes32refers to decentralized identifier seed (a bytes32 length ID).
_checksumbytes32includes a one-way HASH calculated using the DDO content.
_providersaddress[]list of addresses that can act as an asset provider
_urlstringrefers to the url resolving the DID into a DID Document (DDO), limited to 2048 bytes.
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_activityIdbytes32refers to activity
_nftMetadatastringrefers to the url providing the NFT Metadata

enableAndMintDidNft

function enableAndMintDidNft(bytes32 _did, uint256 _cap, uint8 _royalties, bool _mint, string _nftMetadata) public returns (bool success)

enableDidNft creates the initial setup of NFTs minting and royalties distribution for ERC-1155 NFTs. After this initial setup, this data can't be changed anymore for the DID given, even for the owner of the DID. The reason of this is to avoid minting additional NFTs after the initial agreement, what could affect the valuation of NFTs of a DID already created.

update the DID registry providers list by adding the mintCap and royalties configuration

NameTypeDescription
_didbytes32refers to decentralized identifier (a byte32 length ID)
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif is true mint directly the amount capped tokens and lock in the _lockAddress
_nftMetadatastringrefers to the url providing the NFT Metadata

enableAndMintDidNft721

function enableAndMintDidNft721(bytes32 _did, uint8 _royalties, bool _mint, string _nftMetadata) public returns (bool success)

enableAndMintDidNft721 creates the initial setup of NFTs minting and royalties distribution for ERC-721 NFTs. After this initial setup, this data can't be changed anymore for the DID given, even for the owner of the DID. The reason of this is to avoid minting additional NFTs after the initial agreement, what could affect the valuation of NFTs of a DID already created.

update the DID registry providers list by adding the mintCap and royalties configuration

NameTypeDescription
_didbytes32refers to decentralized identifier (a byte32 length ID)
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market
_mintboolif is true mint directly the amount capped tokens and lock in the _lockAddress
_nftMetadatastringrefers to the url providing the NFT Metadata

mint

function mint(bytes32 _did, uint256 _amount, address _receiver) public

Mints a NFT associated to the DID

Because ERC-1155 uses uint256 and DID's are bytes32, there is a conversion between both Only the DID owner can mint NFTs associated to the DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_amountuint256amount to mint
_receiveraddressthe address that will receive the new nfts minted

mint

function mint(bytes32 _did, uint256 _amount) public

mint721

function mint721(bytes32 _did, address _receiver) public

Mints a ERC-721 NFT associated to the DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_receiveraddressthe address that will receive the new nfts minted

mint721

function mint721(bytes32 _did) public

burn

function burn(bytes32 _did, uint256 _amount) public

Burns NFTs associated to the DID

Because ERC-1155 uses uint256 and DID's are bytes32, there is a conversion between both Only the DID owner can burn NFTs associated to the DID

NameTypeDescription
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_amountuint256amount to burn

burn721

function burn721(bytes32 _did) public

DIDRegistryLibrary

All function calls are currently implemented without side effects

DIDRegister

struct DIDRegister {
address owner;
uint8 royalties;
bool nftInitialized;
bool nft721Initialized;
address creator;
bytes32 lastChecksum;
string url;
address lastUpdatedBy;
uint256 blockNumberUpdated;
address[] providers;
address[] delegates;
uint256 nftSupply;
uint256 mintCap;
address royaltyRecipient;
contract IRoyaltyScheme royaltyScheme;
}

DIDRegisterList

struct DIDRegisterList {
mapping(bytes32 &#x3D;&gt; struct DIDRegistryLibrary.DIDRegister) didRegisters;
bytes32[] didRegisterIds;
}

update

function update(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, bytes32 _checksum, string _url) external

update the DID store

access modifiers and storage pointer should be implemented in DIDRegistry

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_checksumbytes32includes a one-way HASH calculated using the DDO content
_urlstringincludes the url resolving to the DID Document (DDO)

initializeNftConfig

function initializeNftConfig(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, uint256 _cap, uint8 _royalties) internal

initializeNftConfig creates the initial setup of NFTs minting and royalties distribution. After this initial setup, this data can't be changed anymore for the DID given, even for the owner of the DID. The reason of this is to avoid minting additional NFTs after the initial agreement, what could affect the valuation of NFTs of a DID already created.

update the DID registry providers list by adding the mintCap and royalties configuration

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_capuint256refers to the mint cap
_royaltiesuint8refers to the royalties to reward to the DID creator in the secondary market The royalties in secondary market for the creator should be between 0% >= x < 100%

initializeNft721Config

function initializeNft721Config(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, uint8 _royalties) internal

areRoyaltiesValid

function areRoyaltiesValid(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) internal view returns (bool)

areRoyaltiesValid checks if for a given DID and rewards distribution, this allocate the
original creator royalties properly

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_amountsuint256[]refers to the amounts to reward
_receiversaddress[]refers to the receivers of rewards
_tokenAddressaddress
NameTypeDescription
[0]booltrue if the rewards distribution respect the original creator royalties

addProvider

function addProvider(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address provider) internal

addProvider add provider to DID registry

update the DID registry providers list by adding a new provider

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
provideraddressthe provider's address

removeProvider

function removeProvider(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _provider) internal returns (bool)

removeProvider remove provider from DID registry

update the DID registry providers list by removing an existing provider

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_provideraddressthe provider's address

updateDIDOwner

function updateDIDOwner(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _newOwner) internal

updateDIDOwner transfer DID ownership to a new owner

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_newOwneraddressthe new DID owner address

isProvider

function isProvider(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _provider) public view returns (bool)

isProvider check whether DID provider exists

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_provideraddressthe provider's address
NameTypeDescription
[0]booltrue if the provider already exists

getProviderIndex

function getProviderIndex(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address provider) private view returns (int256)

getProviderIndex get the index of a provider

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
provideraddressthe provider's address
NameTypeDescription
[0]int256the index if the provider exists otherwise return -1

addDelegate

function addDelegate(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address delegate) internal

addDelegate add delegate to DID registry

update the DID registry delegates list by adding a new delegate

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
delegateaddressthe delegate's address

removeDelegate

function removeDelegate(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _delegate) internal returns (bool)

removeDelegate remove delegate from DID registry

update the DID registry delegates list by removing an existing delegate

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_delegateaddressthe delegate's address

isDelegate

function isDelegate(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address _delegate) public view returns (bool)

isDelegate check whether DID delegate exists

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
_delegateaddressthe delegate's address
NameTypeDescription
[0]booltrue if the delegate already exists

getDelegateIndex

function getDelegateIndex(struct DIDRegistryLibrary.DIDRegisterList _self, bytes32 _did, address delegate) private view returns (int256)

getDelegateIndex get the index of a delegate

NameTypeDescription
_selfstruct DIDRegistryLibrary.DIDRegisterListrefers to storage pointer
_didbytes32refers to decentralized identifier (a byte32 length ID)
delegateaddressthe delegate's address
NameTypeDescription
[0]int256the index if the delegate exists otherwise return -1

ProvenanceRegistry

All function calls are currently implemented without side effects

__ProvenanceRegistry_init

function __ProvenanceRegistry_init() internal

__ProvenanceRegistry_init_unchained

function __ProvenanceRegistry_init_unchained() internal

Provenance

struct Provenance {
bytes32 did;
bytes32 relatedDid;
address agentId;
bytes32 activityId;
address agentInvolvedId;
uint8 method;
address createdBy;
uint256 blockNumberUpdated;
bytes signature;
}

ProvenanceRegistryList

struct ProvenanceRegistryList {
mapping(bytes32 &#x3D;&gt; struct ProvenanceRegistry.Provenance) list;
}

provenanceRegistry

struct ProvenanceRegistry.ProvenanceRegistryList provenanceRegistry

ProvenanceMethod

enum ProvenanceMethod {
ENTITY,
ACTIVITY,
WAS_GENERATED_BY,
USED,
WAS_INFORMED_BY,
WAS_STARTED_BY,
WAS_ENDED_BY,
WAS_INVALIDATED_BY,
WAS_DERIVED_FROM,
AGENT,
WAS_ATTRIBUTED_TO,
WAS_ASSOCIATED_WITH,
ACTED_ON_BEHALF
}

ProvenanceAttributeRegistered

event ProvenanceAttributeRegistered(bytes32 provId, bytes32 _did, address _agentId, bytes32 _activityId, bytes32 _relatedDid, address _agentInvolvedId, enum ProvenanceRegistry.ProvenanceMethod _method, string _attributes, uint256 _blockNumberUpdated)

Provenance Events

WasGeneratedBy

event WasGeneratedBy(bytes32 _did, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

Used

event Used(bytes32 _did, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

WasDerivedFrom

event WasDerivedFrom(bytes32 _newEntityDid, bytes32 _usedEntityDid, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

WasAssociatedWith

event WasAssociatedWith(bytes32 _entityDid, address _agentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

ActedOnBehalf

event ActedOnBehalf(bytes32 _entityDid, address _delegateAgentId, address _responsibleAgentId, bytes32 _activityId, bytes32 provId, string _attributes, uint256 _blockNumberUpdated)

createProvenanceEntry

function createProvenanceEntry(bytes32 _provId, bytes32 _did, bytes32 _relatedDid, address _agentId, bytes32 _activityId, address _agentInvolvedId, enum ProvenanceRegistry.ProvenanceMethod _method, address _createdBy, bytes _signatureDelegate, string _attributes) internal returns (bool)

create an event in the Provenance store

access modifiers and storage pointer should be implemented in ProvenanceRegistry

NameTypeDescription
_provIdbytes32refers to provenance event identifier
_didbytes32refers to decentralized identifier (a byte32 length ID)
_relatedDidbytes32refers to decentralized identifier (a byte32 length ID) of a related entity
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_agentInvolvedIdaddressrefers to address of the agent involved with the provenance record
_methodenum ProvenanceRegistry.ProvenanceMethodrefers to the W3C Provenance method
_createdByaddressrefers to address of the agent triggering the activity
_signatureDelegatebytesrefers to the digital signature provided by the did delegate.
_attributesstring

_wasGeneratedBy

function _wasGeneratedBy(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) internal virtual returns (bool)

Implements the W3C PROV Generation action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity created
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes
NameTypeDescription
[0]boolthe number of the new provenance size

_used

function _used(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, bytes _signatureUsing, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Usage action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity created
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_signatureUsingbytesrefers to the digital signature provided by the agent using the _did
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

_wasDerivedFrom

function _wasDerivedFrom(bytes32 _provId, bytes32 _newEntityDid, bytes32 _usedEntityDid, address _agentId, bytes32 _activityId, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Derivation action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_newEntityDidbytes32refers to decentralized identifier (a bytes32 length ID) of the entity created
_usedEntityDidbytes32refers to decentralized identifier (a bytes32 length ID) of the entity used to derive the new did
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

_wasAssociatedWith

function _wasAssociatedWith(bytes32 _provId, bytes32 _did, address _agentId, bytes32 _activityId, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Association action

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity
_agentIdaddressrefers to address of the agent creating the provenance record
_activityIdbytes32refers to activity
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

_actedOnBehalf

function _actedOnBehalf(bytes32 _provId, bytes32 _did, address _delegateAgentId, address _responsibleAgentId, bytes32 _activityId, bytes _signatureDelegate, string _attributes) internal virtual returns (bool success)

Implements the W3C PROV Delegation action Each party involved in this method (_delegateAgentId & _responsibleAgentId) must provide a valid signature. The content to sign is a representation of the footprint of the event (_did + _delegateAgentId + _responsibleAgentId + _activityId)

NameTypeDescription
_provIdbytes32unique identifier referring to the provenance entry
_didbytes32refers to decentralized identifier (a bytes32 length ID) of the entity
_delegateAgentIdaddressrefers to address acting on behalf of the provenance record
_responsibleAgentIdaddressrefers to address responsible of the provenance record
_activityIdbytes32refers to activity
_signatureDelegatebytesrefers to the digital signature provided by the did delegate.
_attributesstringrefers to the provenance attributes
NameTypeDescription
successbooltrue if the action was properly registered

CurveRoyalties

registry

contract DIDRegistry registry

DENOMINATOR

uint256 DENOMINATOR

royalties

mapping(bytes32 => uint256) royalties

initialize

function initialize(address _registry) public

royaltyCurve

function royaltyCurve(uint256 num, uint256 max, uint256 rate) public pure virtual returns (uint256)

setRoyalty

function setRoyalty(bytes32 _did, uint256 _royalty) public

Set royalties for a DID

Can only be called by creator of the DID

NameTypeDescription
_didbytes32DID for which the royalties are set
_royaltyuint256Royalty, the actual royalty will be _royalty / 10000 percent

check

function check(bytes32 _did, uint256[] _amounts, address[] _receivers, address _token) external view returns (bool)

RewardsDistributor

used

mapping(bytes32 => bool) used

receivers

mapping(bytes32 => address[]) receivers

registry

contract DIDRegistry registry

conditionStoreManager

contract ConditionStoreManager conditionStoreManager

escrow

address escrow

initialize

function initialize(address _registry, address _conditionStoreManager, address _escrow) public

setReceivers

function setReceivers(bytes32 _did, address[] _addr) public

set receivers for did

NameTypeDescription
_didbytes32DID
_addraddress[]list of receivers

claimReward

function claimReward(bytes32 _agreementId, bytes32 _did, uint256[] _amounts, address[] _receivers, address _returnAddress, address _lockPaymentAddress, address _tokenAddress, bytes32 _lockCondition, bytes32[] _releaseConditions) public

distribute rewards associated with an escrow condition

as paramemeters, it just gets the same parameters as fulfill for escrow condition

NameTypeDescription
_agreementIdbytes32agreement identifier
_didbytes32asset decentralized identifier
_amountsuint256[]token amounts to be locked/released
_receiversaddress[]receiver's address
_returnAddressaddress
_lockPaymentAddressaddresslock payment contract address
_tokenAddressaddressthe ERC20 contract address to use during the payment
_lockConditionbytes32lock condition identifier
_releaseConditionsbytes32[]release condition identifier

StandardRoyalties

registry

contract DIDRegistry registry

DENOMINATOR

uint256 DENOMINATOR

royalties

mapping(bytes32 => uint256) royalties

initialize

function initialize(address _registry) public

setRoyalty

function setRoyalty(bytes32 _did, uint256 _royalty) public

Set royalties for a DID

Can only be called by creator of the DID

NameTypeDescription
_didbytes32DID for which the royalties are set
_royaltyuint256Royalty, the actual royalty will be _royalty / 10000 percent

check

function check(bytes32 _did, uint256[] _amounts, address[] _receivers, address) external view returns (bool)

AaveCreditTemplate

_Implementation of the Aaven Credit Agreement Template 0. Initialize the agreement

  1. LockNFT - Delegatee locks the NFT
  2. AaveCollateralDeposit - Delegator deposits the collateral into Aave. And approves the delegation flow
  3. AaveBorrowCondition - The Delegatee claim the credit amount from Aave
  4. AaveRepayCondition. Options: 4.a Fulfilled state - The Delegatee pay back the loan (including fee) into Aave and gets back the NFT 4.b Aborted state - The Delegatee doesn't pay the loan in time so the Delegator gets the NFT. The Delegator pays the loan to Aave
  5. TransferNFT. Options: 5.a if AaveRepayCondition was fulfilled, it will allow transfer back to the Delegatee or Borrower 5.b if AaveRepayCondition was aborted, it will allow transfer the NFT to the Delegator or Lender_

didRegistry

contract DIDRegistry didRegistry

nftLockCondition

contract INFTLock nftLockCondition

depositCondition

contract AaveCollateralDepositCondition depositCondition

borrowCondition

contract AaveBorrowCondition borrowCondition

repayCondition

contract AaveRepayCondition repayCondition

transferCondition

contract DistributeNFTCollateralCondition transferCondition

withdrawCondition

contract AaveCollateralWithdrawCondition withdrawCondition

vaultAddress

mapping(bytes32 => address) vaultAddress

nvmFee

uint256 nvmFee

vaultLibrary

address vaultLibrary

VaultCreated

event VaultCreated(address _vaultAddress, address _creator, address _lender, address _borrower)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _nftLockConditionAddress, address _depositConditionAddress, address _borrowConditionAddress, address _repayConditionAddress, address _withdrawCollateralAddress, address _transferConditionAddress, address _vaultLibrary) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access , lock payment and escrow payment conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_nftLockConditionAddressaddressNFT Lock Condition contract address
_depositConditionAddressaddressAave collateral deposit Condition address
_borrowConditionAddressaddressAave borrow deposit Condition address
_repayConditionAddressaddressAave repay credit Condition address
_withdrawCollateralAddressaddress
_transferConditionAddressaddressNFT Transfer Condition address
_vaultLibraryaddress

createVaultAgreement

function createVaultAgreement(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _vaultAddress) public

createAgreement

function createAgreement(bytes32 _id, address _lendingPool, address _dataProvider, address _weth, uint256 _agreementFee, address _treasuryAddress, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _lender) public

deployVault

function deployVault(address _lendingPool, address _dataProvider, address _weth, uint256 _agreementFee, address _treasuryAddress, address _borrower, address _lender) public returns (address)

getVaultForAgreement

function getVaultForAgreement(bytes32 _agreementId) public view returns (address)

updateNVMFee

function updateNVMFee(uint256 _newFee) public

Updates the nevermined fee for this type of agreement

NameTypeDescription
_newFeeuint256New nevermined fee expressed in basis points

changeCreditVaultLibrary

function changeCreditVaultLibrary(address _vaultLibrary) public

AccessProofTemplate

Implementation of Access Agreement Template

didRegistry

contract DIDRegistry didRegistry

accessCondition

contract AccessProofCondition accessCondition

lockCondition

contract LockPaymentCondition lockCondition

escrowReward

contract EscrowPaymentCondition escrowReward

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress, address _accessConditionAddress, address _lockConditionAddress, address payable _escrowConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access , lock payment and escrow payment conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address
_accessConditionAddressaddressaccess condition address
_lockConditionAddressaddresslock reward condition contract address
_escrowConditionAddressaddress payableescrow reward contract address

AccessTemplate

_Implementation of Access Agreement Template

 Access template is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an on-chain SEA. The template is a composite of three basic
conditions. Once the agreement is created, the consumer will lock an amount
of tokens (as listed in the DID document - off-chain metadata) to the
the lock reward contract which in turn will fire an event. ON the other hand
the provider is listening to all the emitted events, the provider
will catch the event and grant permissions to the consumer through
secret store contract, the consumer now is able to download the data set
by asking the off-chain component of secret store to decrypt the DID and
encrypt it using the consumer's public key. Then the secret store will
provide an on-chain proof that the consumer had access to the data set.
Finally, the provider can call the escrow reward condition in order
to release the payment. Every condition has a time window (time lock and
time out). This implies that if the provider didn't grant the access to
the consumer through secret store within this time window, the consumer
can ask for refund._

didRegistry

contract DIDRegistry didRegistry

accessCondition

contract AccessCondition accessCondition

lockCondition

contract LockPaymentCondition lockCondition

escrowReward

contract EscrowPaymentCondition escrowReward

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress, address _accessConditionAddress, address _lockConditionAddress, address payable _escrowConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access , lock payment and escrow payment conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address
_accessConditionAddressaddressaccess condition address
_lockConditionAddressaddresslock reward condition contract address
_escrowConditionAddressaddress payableescrow reward contract address

AgreementTemplate

_Implementation of Agreement Template

 Agreement template is a reference template where it
has the ability to create agreements from whitelisted
template_

conditionTypes

address[] conditionTypes

agreementStoreManager

contract AgreementStoreManager agreementStoreManager

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts) public

createAgreement create new agreement

NameTypeDescription
_idbytes32agreement unique identifier
_didbytes32refers to decentralized identifier (a bytes32 length ID).
_conditionIdsbytes32[]list of condition identifiers
_timeLocksuint256[]list of time locks, each time lock will be assigned to the same condition that has the same index
_timeOutsuint256[]list of time outs, each time out will be assigned to the same condition that has the same index

createAgreementAndPay

function createAgreementAndPay(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, uint256 _idx, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public payable

createAgreementAndFulfill

function createAgreementAndFulfill(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, uint256[] _indices, address[] _accounts, bytes[] _params) internal

getConditionTypes

function getConditionTypes() public view returns (address[])

getConditionTypes gets the conditions addresses list

for the current template returns list of condition contracts addresses

NameTypeDescription
[0]address[]list of conditions contract addresses

BaseEscrowTemplate

agreementData

struct BaseEscrowTemplate.AgreementData agreementData

AgreementCreated

event AgreementCreated(bytes32 _agreementId, bytes32 _did, address _accessConsumer, address _accessProvider, uint256[] _timeLocks, uint256[] _timeOuts, bytes32[] _conditionIdSeeds, bytes32[] _conditionIds, bytes32 _idSeed, address _creator)

AgreementDataModel

struct AgreementDataModel {
address accessConsumer;
address accessProvider;
bytes32 did;
}

AgreementData

struct AgreementData {
mapping(bytes32 &#x3D;&gt; struct BaseEscrowTemplate.AgreementDataModel) agreementDataItems;
bytes32[] agreementIds;
}

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer) public

createAgreement creates agreements through agreement template

this function initializes the agreement by setting the DID, conditions ID, timeouts, time locks and the consumer address. The DID provider/owner is automatically detected by the DID Registry

NameTypeDescription
_idbytes32SEA agreement unique identifier
_didbytes32Decentralized Identifier (DID)
_conditionIdsbytes32[]conditions ID associated with the condition types
_timeLocksuint256[]the starting point of the time window ,time lock is in block number not seconds
_timeOutsuint256[]the ending point of the time window ,time lock is in block number not seconds
_accessConsumeraddressconsumer address

createAgreementAndPayEscrow

function createAgreementAndPayEscrow(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, uint256 _idx, address payable _rewardAddress, address _tokenAddress, uint256[] _amounts, address[] _receivers) public payable

createAgreementAndFulfill

function createAgreementAndFulfill(bytes32 _id, bytes32 _did, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, uint256[] _indices, address[] _accounts, bytes[] _params) internal

_makeIds

function _makeIds(bytes32 _idSeed, bytes32[] _conditionIds) internal view returns (bytes32[])

_initAgreement

function _initAgreement(bytes32 _idSeed, bytes32 _did, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, bytes32[] _conditionIds) internal

getAgreementData

function getAgreementData(bytes32 _id) external view returns (address accessConsumer, address accessProvider)

getAgreementData return the agreement Data

NameTypeDescription
_idbytes32SEA agreement unique identifier
NameTypeDescription
accessConsumeraddressthe agreement consumer
accessProvideraddressthe provider addresses

DIDSalesTemplate

_Implementation of DID Sales Template

 The DID Sales template supports an scenario where an Asset owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing an Asset owner to get transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer DID Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the ownership transfer of an asset
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

transferCondition

contract TransferDIDOwnershipCondition transferCondition

rewardCondition

contract EscrowPaymentCondition rewardCondition

id

function id() public pure returns (uint256)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockConditionAddress, address _transferConditionAddress, address payable _escrowPaymentAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockConditionAddressaddresslock reward condition contract address
_transferConditionAddressaddresstransfer ownership condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address

DynamicAccessTemplate

Implementation of Agreement Template This is a dynamic template that allows to setup flexible conditions depending on the use case.

didRegistry

contract DIDRegistry didRegistry

templateConfig

struct DynamicAccessTemplate.TemplateConditions templateConfig

TemplateConditions

struct TemplateConditions {
mapping(address &#x3D;&gt; contract Condition) templateConditions;
}

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address

addTemplateCondition

function addTemplateCondition(address _conditionAddress) external returns (uint256 length)

addTemplateCondition adds a new condition to the template

NameTypeDescription
_conditionAddressaddresscondition contract address
NameTypeDescription
lengthuint256conditionTypes array size

removeLastTemplateCondition

function removeLastTemplateCondition() external returns (address[])

removeLastTemplateCondition removes last condition added to the template

NameTypeDescription
[0]address[]conditionTypes existing in the array

EscrowComputeExecutionTemplate

_Implementation of a Compute Execution Agreement Template

 EscrowComputeExecutionTemplate is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an on-chain SEA. The template is a composite of three basic
conditions. Once the agreement is created, the consumer will lock an amount
of tokens (as listed in the DID document - off-chain metadata) to the
the lock reward contract which in turn will fire an event. ON the other hand
the provider is listening to all the emitted events, the provider
will catch the event and grant permissions to trigger a computation granting
the execution via the ComputeExecutionCondition contract.
The consumer now is able to trigger that computation
by asking the off-chain gateway to start the execution of a compute workflow.
Finally, the provider can call the escrow reward condition in order
to release the payment. Every condition has a time window (time lock and
time out). This implies that if the provider didn't grant the execution to
the consumer within this time window, the consumer
can ask for refund._

didRegistry

contract DIDRegistry didRegistry

computeExecutionCondition

contract ComputeExecutionCondition computeExecutionCondition

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

escrowPayment

contract EscrowPaymentCondition escrowPayment

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _didRegistryAddress, address _computeExecutionConditionAddress, address _lockPaymentConditionAddress, address payable _escrowPaymentAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including service executor condition, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_didRegistryAddressaddressDID registry contract address
_computeExecutionConditionAddressaddressservice executor condition contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_escrowPaymentAddressaddress payableescrow reward contract address

name

function name() public pure returns (string)

NFT721AccessProofTemplate

Implementation of NFT721 Access Proof Template

NFT721AccessSwapTemplate

NFT721AccessTemplate

Implementation of NFT Access Template

NFT721SalesTemplate

Implementation of NFT Sales Template

NFT721SalesWithAccessTemplate

NFTAccessProofTemplate

_Implementation of NFT Access Template

 The NFT Access template is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing NFT holders to get access to Nevermined services.
The template is a composite of 2 basic conditions:
- NFT Holding Condition
- Access Condition

Once the agreement is created, the consumer can demonstrate is holding a NFT
for a specific DID. If that's the case the Access condition can be fulfilled
by the asset owner or provider and all the agreement is fulfilled.
This can be used in scenarios where a data or services owner, can allow
users to get access to exclusive services only when they demonstrate the
are holding a specific number of NFTs of a DID.
This is very useful in use cases like arts._

didRegistry

contract DIDRegistry didRegistry

nftHolderCondition

contract INFTHolder nftHolderCondition

accessCondition

contract AccessProofCondition accessCondition

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _nftHolderConditionAddress, address _accessConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_nftHolderConditionAddressaddresslock reward condition contract address
_accessConditionAddressaddressaccess condition contract address

NFTAccessSwapTemplate

_Implementation of NFT Sales Template

 The NFT Sales template supports an scenario where a NFT owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing a NFT owner to transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer NFT Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the transfer of the NFT
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract INFTLock lockPaymentCondition

rewardCondition

contract INFTEscrow rewardCondition

accessCondition

contract AccessProofCondition accessCondition

id

function id() public pure returns (uint256)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockPaymentConditionAddress, address payable _escrowPaymentAddress, address _accessCondition) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address
_accessConditionaddress

NFTAccessTemplate

_Implementation of NFT Access Template

 The NFT Access template is use case specific template.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing NFT holders to get access to Nevermined services.
The template is a composite of 2 basic conditions:
- NFT Holding Condition
- Access Condition

Once the agreement is created, the consumer can demonstrate is holding a NFT
for a specific DID. If that's the case the Access condition can be fulfilled
by the asset owner or provider and all the agreement is fulfilled.
This can be used in scenarios where a data or services owner, can allow
users to get access to exclusive services only when they demonstrate the
are holding a specific number of NFTs of a DID.
This is very useful in use cases like arts._

didRegistry

contract DIDRegistry didRegistry

nftHolderCondition

contract INFTHolder nftHolderCondition

accessCondition

contract INFTAccess accessCondition

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _nftHolderConditionAddress, address _accessConditionAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_nftHolderConditionAddressaddresslock reward condition contract address
_accessConditionAddressaddressaccess condition contract address

NFTSalesTemplate

_Implementation of NFT Sales Template

 The NFT Sales template supports an scenario where a NFT owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing a NFT owner to transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer NFT Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the transfer of the NFT
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

transferCondition

contract ITransferNFT transferCondition

rewardCondition

contract EscrowPaymentCondition rewardCondition

id

function id() public pure returns (uint256)

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockPaymentConditionAddress, address _transferConditionAddress, address payable _escrowPaymentAddress) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_transferConditionAddressaddresstransfer NFT condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address

nftPrice

mapping(address => mapping(address => mapping(address => mapping(bytes32 => uint256)))) nftPrice

nftSale

function nftSale(address nftAddress, bytes32 nftId, address token, uint256 amount) external

checkParamsTransfer

function checkParamsTransfer(bytes[] _params, bytes32 lockPaymentConditionId, bytes32 _did) internal view returns (address)

checkParamsEscrow

function checkParamsEscrow(bytes[] _params, bytes32 lockPaymentId, bytes32 transferId) internal pure

createAgreementFulfill

function createAgreementFulfill(bytes32 _id, bytes32 _did, uint256[] _timeLocks, uint256[] _timeOuts, address _accessConsumer, bytes[] _params) external payable

NFTSalesWithAccessTemplate

_Implementation of NFT Sales Template

 The NFT Sales template supports an scenario where a NFT owner
can sell that asset to a new Owner.
Anyone (consumer/provider/publisher) can use this template in order
to setup an agreement allowing a NFT owner to transfer the asset ownership
after some payment.
The template is a composite of 3 basic conditions:
- Lock Payment Condition
- Transfer NFT Condition
- Escrow Reward Condition

This scenario takes into account royalties for original creators in the secondary market.
Once the agreement is created, the consumer after payment can request the transfer of the NFT
from the current owner for a specific DID._

didRegistry

contract DIDRegistry didRegistry

lockPaymentCondition

contract LockPaymentCondition lockPaymentCondition

transferCondition

contract ITransferNFT transferCondition

rewardCondition

contract EscrowPaymentCondition rewardCondition

accessCondition

contract AccessProofCondition accessCondition

initialize

function initialize(address _owner, address _agreementStoreManagerAddress, address _lockPaymentConditionAddress, address _transferConditionAddress, address payable _escrowPaymentAddress, address _accessCondition) external

initialize init the contract with the following parameters.

this function is called only once during the contract initialization. It initializes the ownable feature, and set push the required condition types including access secret store, lock reward and escrow reward conditions.

NameTypeDescription
_owneraddresscontract's owner account address
_agreementStoreManagerAddressaddressagreement store manager contract address
_lockPaymentConditionAddressaddresslock reward condition contract address
_transferConditionAddressaddresstransfer NFT condition contract address
_escrowPaymentAddressaddress payableescrow reward condition contract address
_accessConditionaddress

TemplateStoreLibrary

_Implementation of the Template Store Library.

 Templates are blueprints for modular SEAs. When 
creating an Agreement, a templateId defines the condition
and reward types that are instantiated in the ConditionStore._

TemplateState

enum TemplateState {
Uninitialized,
Proposed,
Approved,
Revoked
}

Template

struct Template {
enum TemplateStoreLibrary.TemplateState state;
address owner;
address lastUpdatedBy;
uint256 blockNumberUpdated;
}

TemplateList

struct TemplateList {
mapping(address &#x3D;&gt; struct TemplateStoreLibrary.Template) templates;
address[] templateIds;
}

propose

function propose(struct TemplateStoreLibrary.TemplateList _self, address _id) internal returns (uint256 size)

propose new template

NameTypeDescription
_selfstruct TemplateStoreLibrary.TemplateListis the TemplateList storage pointer
_idaddressproposed template contract address
NameTypeDescription
sizeuint256which is the index of the proposed template

approve

function approve(struct TemplateStoreLibrary.TemplateList _self, address _id) internal

approve new template

NameTypeDescription
_selfstruct TemplateStoreLibrary.TemplateListis the TemplateList storage pointer
_idaddressproposed template contract address

revoke

function revoke(struct TemplateStoreLibrary.TemplateList _self, address _id) internal

revoke new template

NameTypeDescription
_selfstruct TemplateStoreLibrary.TemplateListis the TemplateList storage pointer
_idaddressapproved template contract address

TemplateStoreManager

Implementation of the Template Store Manager. Templates are blueprints for modular SEAs. When creating an Agreement, a templateId defines the condition and reward types that are instantiated in the ConditionStore. This contract manages the life cycle of the template ( Propose --> Approve --> Revoke ).

templateList

struct TemplateStoreLibrary.TemplateList templateList

onlyOwnerOrTemplateOwner

modifier onlyOwnerOrTemplateOwner(address _id)

initialize

function initialize(address _owner) public

initialize TemplateStoreManager Initializer Initializes Ownable. Only on contract creation.

NameTypeDescription
_owneraddressrefers to the owner of the contract

proposeTemplate

function proposeTemplate(address _id) external returns (uint256 size)

proposeTemplate proposes a new template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address

approveTemplate

function approveTemplate(address _id) external

approveTemplate approves a template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address. Only template store manager owner (i.e OPNF) can approve this template.

revokeTemplate

function revokeTemplate(address _id) external

revokeTemplate revoke a template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address. Only template store manager owner (i.e OPNF) or template owner can revoke this template.

getTemplate

function getTemplate(address _id) external view returns (enum TemplateStoreLibrary.TemplateState state, address owner, address lastUpdatedBy, uint256 blockNumberUpdated)

getTemplate get more information about a template

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address.
NameTypeDescription
stateenum TemplateStoreLibrary.TemplateStatetemplate status
owneraddresstemplate owner
lastUpdatedByaddresslast updated by
blockNumberUpdateduint256last updated at.

getTemplateListSize

function getTemplateListSize() external view virtual returns (uint256 size)

getTemplateListSize number of templates

NameTypeDescription
sizeuint256number of templates

isTemplateApproved

function isTemplateApproved(address _id) external view returns (bool)

isTemplateApproved check whether the template is approved

NameTypeDescription
_idaddressunique template identifier which is basically the template contract address.
NameTypeDescription
[0]booltrue if the template is approved

AgreementStoreManagerChangeFunctionSignature

createAgreement

function createAgreement(bytes32 _id, bytes32 _did, address[] _conditionTypes, bytes32[] _conditionIds, uint256[] _timeLocks, uint256[] _timeOuts, address _creator, address _sender) public

AgreementStoreManagerChangeInStorage

agreementCount

uint256 agreementCount

AgreementStoreManagerChangeInStorageAndLogic

AgreementStoreManagerExtraFunctionality

dummyFunction

function dummyFunction() public pure returns (bool)

AgreementStoreManagerWithBug

getDIDRegistryAddress

function getDIDRegistryAddress() public pure returns (address)

getDIDRegistryAddress utility function used by other contracts or any EOA.

NameTypeDescription
[0]addressthe DIDRegistry address

ConditionStoreChangeFunctionSignature

createCondition

function createCondition(bytes32 _id, address _typeRef, address _sender) public

ConditionStoreChangeInStorage

conditionCount

uint256 conditionCount

ConditionStoreChangeInStorageAndLogic

ConditionStoreExtraFunctionality

dummyFunction

function dummyFunction() public pure returns (bool)

ConditionStoreWithBug

getConditionState

function getConditionState(bytes32 _id) public view returns (enum ConditionStoreLibrary.ConditionState)

getConditionState

NameTypeDescription
[0]enum ConditionStoreLibrary.ConditionStatecondition state

DIDRegistryChangeFunctionSignature

registerAttribute

function registerAttribute(bytes32 _didSeed, address[] _providers, bytes32 _checksum, string _url) public

DIDRegistryChangeInStorage

timeOfRegister

mapping(bytes32 => uint256) timeOfRegister

DIDRegistryChangeInStorageAndLogic

DIDRegistryExtraFunctionality

getNumber

function getNumber() public pure returns (uint256)

DIDRegistryWithBug

registerAttribute

function registerAttribute(bytes32 _checksum, bytes32 _didSeed, address[] _providers, string _url) public

registerAttribute is called only by DID owner.

this function registers DID attributes

NameTypeDescription
_checksumbytes32includes a one-way HASH calculated using the DDO content
_didSeedbytes32refers to decentralized identifier (a byte32 length ID)
_providersaddress[]
_urlstringrefers to the attribute value

IPNFT

TokenURIChanged

event TokenURIChanged(uint256 tokenId, string newURI)

initialize

function initialize(string _name, string _symbol) public

setTokenURI

function setTokenURI(uint256 tokenId, string _tokenURI) public

mint

function mint(address to, uint256 _tokenId, string _tokenURI) public returns (bool)

mintWithoutTokenURI

function mintWithoutTokenURI(address to, uint256 _tokenId) external

transfer

function transfer(address from, address to, uint256 _tokenId) public

NeverminedConfigChangeInStorage

newVariable

uint256 newVariable

NeverminedConfigChangeFunctionSignature

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver, uint256 _newParameter) external virtual

NeverminedConfigChangeInStorageAndLogic

NeverminedConfigWithBug

setMarketplaceFees

function setMarketplaceFees(uint256 _marketplaceFee, address _feeReceiver) external virtual

The governor can update the Nevermined Marketplace fees

NameTypeDescription
_marketplaceFeeuint256new marketplace fee
_feeReceiveraddressThe address receiving the fee

TemplateStoreChangeFunctionSignature

proposeTemplate

function proposeTemplate(address _id, address _sender) external returns (uint256 size)

TemplateStoreChangeInStorage

templateCount

uint256 templateCount

TemplateStoreChangeInStorageAndLogic

TemplateStoreExtraFunctionality

dummyFunction

function dummyFunction() public pure returns (bool)

TemplateStoreWithBug

getTemplateListSize

function getTemplateListSize() external view returns (uint256 size)

getTemplateListSize number of templates

NameTypeDescription
sizeuint256number of templates

TestERC721

initialize

function initialize() public

mint

function mint(uint256 id) public

DIDRegistryLibraryProxy

didRegister

struct DIDRegistryLibrary.DIDRegister didRegister

didRegisterList

struct DIDRegistryLibrary.DIDRegisterList didRegisterList

areRoyaltiesValid

function areRoyaltiesValid(bytes32 _did, uint256[] _amounts, address[] _receivers, address _tokenAddress) public view returns (bool)

updateDIDOwner

function updateDIDOwner(bytes32 _did, address _newOwner) public

update

function update(bytes32 _did, bytes32 _checksum, string _url) public

initializeNftConfig

function initializeNftConfig(bytes32 _did, uint256 _cap, uint8 _royalties) public

initializeNft721Config

function initializeNft721Config(bytes32 _did, uint8 _royalties) public

getDIDInfo

function getDIDInfo(bytes32 _did) public view returns (address owner, address creator, uint256 royalties)

EpochLibraryProxy

epoch

struct EpochLibrary.Epoch epoch

epochList

struct EpochLibrary.EpochList epochList

create

function create(bytes32 _id, uint256 _timeLock, uint256 _timeOut) external

HashListLibraryProxy

testData

struct HashListLibrary.List testData

initialize

function initialize(address _owner) public

hash

function hash(address _address) public pure returns (bytes32)

add

function add(bytes32[] values) external returns (bool)

add

function add(bytes32 value) external returns (bool)

update

function update(bytes32 oldValue, bytes32 newValue) external returns (bool)

index

function index(uint256 from, uint256 to) external returns (bool)

has

function has(bytes32 value) external view returns (bool)

remove

function remove(bytes32 value) external returns (bool)

get

function get(uint256 _index) external view returns (bytes32)

size

function size() external view returns (uint256)

all

function all() external view returns (bytes32[])

indexOf

function indexOf(bytes32 value) external view returns (uint256)

ownedBy

function ownedBy() external view returns (address)

isIndexed

function isIndexed() external view returns (bool)

NFTBase

Implementation of the Royalties EIP-2981 base contract See https://eips.ethereum.org/EIPS/eip-2981

_proxyApprovals

mapping(address => bool) _proxyApprovals

MINTER_ROLE

bytes32 MINTER_ROLE

RoyaltyInfo

struct RoyaltyInfo {
address receiver;
uint256 royaltyAmount;
}

NFTMetadata

struct NFTMetadata {
string nftURI;
}

_royalties

mapping(uint256 => struct NFTBase.RoyaltyInfo) _royalties

_metadata

mapping(uint256 => struct NFTBase.NFTMetadata) _metadata

_expiration

mapping(address => uint256) _expiration

ProxyApproval

event ProxyApproval(address sender, address operator, bool approved)

Event for recording proxy approvals.

setProxyApproval

function setProxyApproval(address operator, bool approved) public virtual

_setNFTMetadata

function _setNFTMetadata(uint256 tokenId, string tokenURI) internal

_setTokenRoyalty

function _setTokenRoyalty(uint256 tokenId, address receiver, uint256 royaltyAmount) internal

royaltyInfo

function royaltyInfo(uint256 tokenId, uint256 value) external view returns (address receiver, uint256 royaltyAmount)

@inheritdoc IERC2981Upgradeable

NFTUpgradeable

Implementation of the basic standard multi-token. See https://eips.ethereum.org/EIPS/eip-1155

initialize

function initialize(string uri_) public

See {_setURI}.

isApprovedForAll

function isApprovedForAll(address account, address operator) public view virtual returns (bool)

See {IERC1155-isApprovedForAll}.

mint

function mint(address to, uint256 id, uint256 amount, bytes data) public

burn

function burn(address to, uint256 id, uint256 amount) public

addMinter

function addMinter(address account) public

uri

function uri(uint256 tokenId) public view returns (string)

setNFTMetadata

function setNFTMetadata(uint256 tokenId, string nftURI) public

Record some NFT Metadata

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
nftURIstringthe URI (https, ipfs, etc) to the metadata describing the NFT

setTokenRoyalty

function setTokenRoyalty(uint256 tokenId, address receiver, uint256 royaltyAmount) public

Record the asset royalties

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
receiveraddressthe receiver of the royalties (the original creator)
royaltyAmountuint256percentage (no decimals, between 0 and 100)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

NFT721SubscriptionUpgradeable

mint

function mint(address to, uint256 id, uint256 expirationBlock) public

_This mint function allows to define when the NFT expires. The minter should calculate this block number depending on the network velocity

TransferNFT721Condition needs to have the MINTER_ROLE_

balanceOf

function balanceOf(address owner) public view returns (uint256)

See {IERC721-balanceOf}.

NFT721Upgradeable

Implementation of the basic standard multi-token.

initializeWithName

function initializeWithName(string name, string symbol) public virtual

initialize

function initialize() public virtual

isApprovedForAll

function isApprovedForAll(address account, address operator) public view virtual returns (bool)

See {IERC1155-isApprovedForAll}.

addMinter

function addMinter(address account) public

mint

function mint(address to, uint256 id) public virtual

burn

function burn(uint256 id) public

tokenURI

function tokenURI(uint256 tokenId) public view virtual returns (string)

See {IERC721Metadata-tokenURI}.

setNFTMetadata

function setNFTMetadata(uint256 tokenId, string nftURI) public

Record some NFT Metadata

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
nftURIstringthe URI (https, ipfs, etc) to the metadata describing the NFT

setTokenRoyalty

function setTokenRoyalty(uint256 tokenId, address receiver, uint256 royaltyAmount) public

Record the asset royalties

NameTypeDescription
tokenIduint256the id of the asset with the royalties associated
receiveraddressthe receiver of the royalties (the original creator)
royaltyAmountuint256percentage (no decimals, between 0 and 100)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

POAPUpgradeable

_tokenIdCounter

struct CountersUpgradeable.Counter _tokenIdCounter

_tokenEvent

mapping(uint256 => uint256) _tokenEvent

initialize

function initialize() public

initializeWithName

function initializeWithName(string name, string symbol) public virtual

mint

function mint(address to, string uri, uint256 eventId) public

mint

function mint(address to, uint256 id) public

tokenEvent

function tokenEvent(uint256 tokenId) public view returns (uint256)

_beforeTokenTransfer

function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal

_burn

function _burn(uint256 tokenId) internal

tokenDetailsOfOwner

function tokenDetailsOfOwner(address owner) public view returns (uint256[] tokenIds, uint256[] eventIds)

tokenURI

function tokenURI(uint256 tokenId) public view returns (string)

isApprovedForAll

function isApprovedForAll(address account, address operator) public view returns (bool)

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

TestDisputeManager

accept

mapping(bytes32 => bool) accept

accepted

function accepted(address provider, address buyer, bytes32 orig, bytes32 crypted) public view returns (bool)

setAccepted

function setAccepted(bytes32 orig, bytes32 crypted, address provider, address buyer) public

PlonkVerifier

n

uint32 n

nPublic

uint16 nPublic

nLagrange

uint16 nLagrange

Qmx

uint256 Qmx

Qmy

uint256 Qmy

Qlx

uint256 Qlx

Qly

uint256 Qly

Qrx

uint256 Qrx

Qry

uint256 Qry

Qox

uint256 Qox

Qoy

uint256 Qoy

Qcx

uint256 Qcx

Qcy

uint256 Qcy

S1x

uint256 S1x

S1y

uint256 S1y

S2x

uint256 S2x

S2y

uint256 S2y

S3x

uint256 S3x

S3y

uint256 S3y

k1

uint256 k1

k2

uint256 k2

X2x1

uint256 X2x1

X2x2

uint256 X2x2

X2y1

uint256 X2y1

X2y2

uint256 X2y2

q

uint256 q

qf

uint256 qf

w1

uint256 w1

G1x

uint256 G1x

G1y

uint256 G1y

G2x1

uint256 G2x1

G2x2

uint256 G2x2

G2y1

uint256 G2y1

G2y2

uint256 G2y2

pA

uint16 pA

pB

uint16 pB

pC

uint16 pC

pZ

uint16 pZ

pT1

uint16 pT1

pT2

uint16 pT2

pT3

uint16 pT3

pWxi

uint16 pWxi

pWxiw

uint16 pWxiw

pEval_a

uint16 pEval_a

pEval_b

uint16 pEval_b

pEval_c

uint16 pEval_c

pEval_s1

uint16 pEval_s1

pEval_s2

uint16 pEval_s2

pEval_zw

uint16 pEval_zw

pEval_r

uint16 pEval_r

pAlpha

uint16 pAlpha

pBeta

uint16 pBeta

pGamma

uint16 pGamma

pXi

uint16 pXi

pXin

uint16 pXin

pBetaXi

uint16 pBetaXi

pV1

uint16 pV1

pV2

uint16 pV2

pV3

uint16 pV3

pV4

uint16 pV4

pV5

uint16 pV5

pV6

uint16 pV6

pU

uint16 pU

pPl

uint16 pPl

pEval_t

uint16 pEval_t

pA1

uint16 pA1

pB1

uint16 pB1

pZh

uint16 pZh

pZhInv

uint16 pZhInv

pEval_l1

uint16 pEval_l1

pEval_l2

uint16 pEval_l2

pEval_l3

uint16 pEval_l3

pEval_l4

uint16 pEval_l4

pEval_l5

uint16 pEval_l5

pEval_l6

uint16 pEval_l6

pEval_l7

uint16 pEval_l7

lastMem

uint16 lastMem

verifyProof

function verifyProof(bytes proof, uint256[] pubSignals) public view returns (bool)