npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@polydocs/contracts

v1.0.1

Published

PolyDocs: an open-source tool to create immutable and dynamic documents using IPFS and Polygon smart contracts. Our goal is to De-Risk the web3 space.

Downloads

12

Readme

Polydocs contracts

PolyDocs: an open-source tool to create immutable and dynamic documents using IPFS and Polygon smart contracts. Our goal is to De-Risk the web3 space.

Finalist: HackFS 2022

Interfaces

  • MetadataURI.sol: Interface for adding Metadata on contract level
  • Signable.sol: Interface that allows for signing of terms
  • TokenSignable.sol: Interface that allows for signing of token specific terms
  • TermReader.sol - Interface for termsreader contracts
  • TokenTermReader.sol - Interface for token termsreader contracts

Contracts

  • TermsableBase.sol - Abstract contract that implements the TermReader and Metadata interfaces and provides the base functionality for termsable contracts
  • TermsableNoToken.sol - Abstract contract that inherits TermsableBase.sol, implements Signable.sol and provides functionality for acceptance of Terms that are not token specific
  • TokenTermsable.sol - Abstract contract that inherits TermsableBase.sol , implements TokenTermReader and TokenSignable interfaces and provides functionality for acceptance of terms that are token specific

Contract Registry

  • TemplateRegistery - list and ability to vote on the credibility of templates to start to build reputation management

NPM Package

Overview

Installation

npm install @polydocs/contracts

Usage

Once installed, you can use the contracts in the library by importing them:

pragma solidity ^0.8.9;

import "@polydocs/contracts/TermsableNoToken.sol";

contract MyCollectible is ERC721 is TermsableNoToken {
    constructor() ERC721("MyCollectible", "MCO") {
    }
    // Adds terms restrictions while transferring a token
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        require(_acceptedTerms(to), "Terms not accepted");
        super._transfer(from, to, tokenId);
    }

    // Adds terms restrictions while minting a token
    function _safeMint(address _to, uint256 _tokenId) internal override {
        require(_acceptedTerms(_to), "Terms not accepted");
        super._safeMint(_to, _tokenId);
    }
}

License

Polydocs Contracts is released under the MIT License.# Solidity API

MetadataURI

UpdatedURI

event UpdatedURI(string uri)

Event that is emitted when contract URI is updated.

This event is emitted when contract URI is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | uri | string | The new contract URI. |

URI

function URI() external view returns (string _uri)

This function is used to return the contract URI

Function to return the contract URI

| Name | Type | Description | | ---- | ---- | ----------- | | _uri | string | The contract URI |

Signable

AcceptedTerms

event AcceptedTerms(address sender, string terms)

Event that is emitted when a terms are accepted.

This event is emitted when a terms are accepted.

| Name | Type | Description | | ---- | ---- | ----------- | | sender | address | The address that accepted the terms. | | terms | string | The terms that were accepted. |

termsUrlWithPrefix

function termsUrlWithPrefix(string prefix) external view returns (string)

This function returns the terms url with a given prefix.

This function returns the terms url with a given prefix.

| Name | Type | Description | | ---- | ---- | ----------- | | prefix | string | The prefix to add to the terms url. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | The terms url with the prefix. |

termsUrl

function termsUrl() external view returns (string)

This function returns the terms url.

This function returns the terms url.

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | The terms url. |

acceptTerms

function acceptTerms(string _newtermsUrl) external

This function is used to accept the terms at certain url

This function is called by a user that wants to accepts terms.

| Name | Type | Description | | ---- | ---- | ----------- | | _newtermsUrl | string | The url of the terms. |

acceptTermsFor

function acceptTermsFor(address _signer, string _newtermsUrl, bytes _signature) external

This function is used to accept the terms at certain url on behalf of the user (metasigner)

This function is called by a metasigner to accept terms on behalf of the signer that wants to accepts terms.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that wants to accept terms. | | _newtermsUrl | string | The url of the terms. | | _signature | bytes | The signature of the signer that wants to accept terms. |

acceptedTerms

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

This function returns whether or not a user has accepted the terms.

This function returns whether or not a user has accepted the terms.

| Name | Type | Description | | ---- | ---- | ----------- | | _address | address | The address of the user. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | bool | True if the user has accepted the terms, false otherwise. |

TermReader

GlobalTermChanged

event GlobalTermChanged(bytes32 _term, bytes32 _value)

This event is fired when a token term is added.

Event when a new Global term is added to the contract

| Name | Type | Description | | ---- | ---- | ----------- | | _term | bytes32 | The term being added to the contract | | _value | bytes32 | value of the term added to the contract |

GlobalRendererChanged

event GlobalRendererChanged(string _renderer)

This event is emitted when the global renderer is updated.

This event is emitted when the global renderer is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _renderer | string | The new renderer. |

GlobalTemplateChanged

event GlobalTemplateChanged(string _template)

This event is emitted when the global template is updated.

This event is emitted when the global template is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _template | string | The new template. |

globalTerm

function globalTerm(string _term) external view returns (string _value)

This function is used to return the value of the term

Function to return the value of the term

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term to get |

| Name | Type | Description | | ---- | ---- | ----------- | | _value | string | The value of the term |

TokenSignable

AcceptedTerms

event AcceptedTerms(address sender, uint256 tokenId, string terms)

Event that is emitted when a terms are accepted.

This event is emitted when a terms are accepted by an address for a specific token and terms agreement

| Name | Type | Description | | ---- | ---- | ----------- | | sender | address | The address that accepted the terms. | | tokenId | uint256 | The token id for which the terms are accepted. | | terms | string | The terms that were accepted. |

acceptedTerms

function acceptedTerms(address to, uint256 tokenId) external view returns (bool)

This is an external function that returns whether the address has accepted terms for a specific token.

This function returns a boolean value indicating whether the address has accepted terms for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | to | address | The address to check. | | tokenId | uint256 | The token id to check. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | bool | _acceptedTerms(to, tokenId) True if the address has accepted terms for a specific token, false otherwise. |

acceptTerms

function acceptTerms(uint256 tokenId, string newtermsUrl) external

This is external function that the user can call to accept specific terms for a specific token.

This function accepts specific terms agreement mentioned on a URL for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the terms are accepted. | | newtermsUrl | string | The terms that are accepted. |

acceptTermsFor

function acceptTermsFor(address _signer, string _newtermsUrl, uint256 _tokenId, bytes _signature) external

This function is used to accept the terms at certain url on behalf of the user (metasigner) for a specific token.

This function is called by a metasigner to accept terms on behalf of the signer that wants to accepts terms for a specific token. It uses ECDSA to recover the signer from the signature and the hash of the termsurl and checks if they match.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that wants to accept terms. | | _newtermsUrl | string | The url of the terms. | | _tokenId | uint256 | The token id for which the terms are accepted. | | _signature | bytes | The signature of the signer that wants to accept terms. |

termsUrl

function termsUrl(uint256 tokenId) external view returns (string)

This is an external function that returns the URL for the agreement for a specific token.

This function returns the URL for the agreement for a specific token with prefix "ipfs://".

termsUrlWithPrefix

function termsUrlWithPrefix(uint256 tokenId, string prefix) external view returns (string)

This is an external function that returns the URL of the agreement for a specific token.

This function returns the URL of the agreement for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the terms URL is returned. | | prefix | string | The prefix to be added to the URL. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _termsUrlWithPrefix(tokenId, prefix) The URL of the terms agreement for a specific token with a given prefix. |

TokenTermReader

TokenTermChanged

event TokenTermChanged(bytes32 _term, uint256 _tokenId, bytes32 _value)

Event emitted when a new token term is added.

Event emitted when a new token term is added.

| Name | Type | Description | | ---- | ---- | ----------- | | _term | bytes32 | The term being added to the contract. | | _tokenId | uint256 | The token id of the token for which the term is being added. | | _value | bytes32 | The value of the term being added to the contract. |

TokenRendererChanged

event TokenRendererChanged(uint256 _tokenId, string _renderer)

This event is emitted when the global renderer is updated.

This event is emitted when the global renderer is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _tokenId | uint256 | The token id of the token for which the renderer is being updated. | | _renderer | string | The new renderer. |

TokenTemplateChanged

event TokenTemplateChanged(uint256 _tokenId, string _template)

This event is emitted when the global template is updated.

This event is emitted when the global template is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _tokenId | uint256 | The token id of the token for which the template is being updated. | | _template | string | The new template. |

tokenTerm

function tokenTerm(string _term, uint256 _tokenId) external view returns (string _value)

This function is used to return the value of the term for a specific token.

This function returns the value of a term given its term for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term to get | | _tokenId | uint256 | The token id of the token for which the term's value is being returned. |

| Name | Type | Description | | ---- | ---- | ----------- | | _value | string | The value of the term. |

TemplateRegistry

Template

struct Template {
  string name;
  string cid;
  int256 score;
  string MetadataURI;
  address owner;
}

templates

struct TemplateRegistry.Template[] templates

Array that stores all the templates

indexes

mapping(string => uint256) indexes

Mapping that stores the mapping of template cid to template index

minfee

uint256 minfee

Minimum fee to score a template

TemplateAdded

event TemplateAdded(address owner, uint256 index)

This event is emitted when a template is added to the registry

This event is emitted when a template is added to the registry

| Name | Type | Description | | ---- | ---- | ----------- | | owner | address | The owner of the template | | index | uint256 | The index of the template in the registry |

add

function add(struct TemplateRegistry.Template _template) public

This function let's a user add a template to the registry

This function let's a user add a template of type Template structure to the registry and emits the TemplateAdded event.

| Name | Type | Description | | ---- | ---- | ----------- | | _template | struct TemplateRegistry.Template | The template of type struct Template to add to the registry |

template

function template(uint256 _index) public view returns (struct TemplateRegistry.Template)

This function returns the template at a certain index

This function returns the template at a certain index

| Name | Type | Description | | ---- | ---- | ----------- | | _index | uint256 | The index of the template to return |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | struct TemplateRegistry.Template | The template of type Template at the given index |

templatebyCID

function templatebyCID(string _cid) public view returns (struct TemplateRegistry.Template)

This function returns the template given a cid

This function returns the template given a cid

| Name | Type | Description | | ---- | ---- | ----------- | | _cid | string | The cid of the template to return |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | struct TemplateRegistry.Template | The template of type Template at the given cid |

count

function count() public view returns (uint256)

This function returns the number of templates in the registry

indexOf

function indexOf(string _cid) public view returns (uint256)

This function returns the index of a template given a cid

This function returns the index of a template given a cid

| Name | Type | Description | | ---- | ---- | ----------- | | _cid | string | The cid of the template to return the index of |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | uint256 | The index of the template in the registry |

upvote

function upvote(string _cid) public payable

This function let's a user upvote a template to increase its reputation score

This is a payable function let's a user upvote a template given it's cid to increase its reputation score This function also checks if the user has paid atleast the minimum fee to score a template

| Name | Type | Description | | ---- | ---- | ----------- | | _cid | string | The cid of the template to upvote |

downvote

function downvote(string _cid) public payable

This function let's a user downvote a template to increase its reputation score

This is a payable function let's a user downvote a template given it's cid to decrease its reputation score This function also checks if the user has paid atleast the minimum fee to score a template

| Name | Type | Description | | ---- | ---- | ----------- | | _cid | string | The cid of the template to downvote |

score

function score(string _cid) public view returns (int256)

This function returns the reputation score of a template given a cid

This function returns the reputation score of a template given a cid

| Name | Type | Description | | ---- | ---- | ----------- | | _cid | string | The cid of the template to return the reputation score of |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | int256 | The reputation score of the template |

TermsableBase

_globalRenderer

string _globalRenderer

The default value of the global renderer.

The default value of the global renderer.

_globalDocTemplate

string _globalDocTemplate

The default value of the global template.

The default value of the global template.

_uri

string _uri

_globalTerms

mapping(string => string) _globalTerms

Mapping that store the global terms.

This mapping stores the global terms.

_lastTermChange

uint256 _lastTermChange

This is the latest block height at which the terms were updated.

This is the latest block height at which the terms were updated. 0 by default.

_metaSigners

mapping(address => bool) _metaSigners

Returns whether the address is allowed to accept terms on behalf of the signer.

This function returns whether the address is allowed to accept terms on behalf of the signer.

onlyMetaSigner

modifier onlyMetaSigner()

This modifier requires that the msg.sender is either the owner of the contract or an approved metasigner

addMetaSigner

function addMetaSigner(address _signer) external

Adds a meta signer to the list of signers that can accept terms on behalf of the signer.

This function adds a meta signer to the list of signers that can accept terms on behalf of the signer. This function is only available to the owner of the contract.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that can accept terms on behalf of the signer. |

_addMetaSigner

function _addMetaSigner(address _signer) internal

Adds a meta signer to the list of signers that can accept terms on behalf of the signer.

This internal function adds a meta signer to the list of signers that can accept terms on behalf of the signer.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that can accept terms on behalf of the signer. |

removeMetaSigner

function removeMetaSigner(address _signer) external

Removes a meta signer from the list of signers that can accept terms on behalf of the signer.

This function removes a meta signer from the list of signers that can accept terms on behalf of the signer. This function is only available to the owner of the contract.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that can no longer accept terms on behalf of the signer. |

_removeMetaSigner

function _removeMetaSigner(address _signer) internal

Removes a meta signer from the list of signers that can accept terms on behalf of the signer.

This internal function removes a meta signer from the list of signers that can accept terms on behalf of the signer.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that can no longer accept terms on behalf of the signer. |

isMetaSigner

function isMetaSigner(address _signer) public view returns (bool)

Returns whether the address is allowed to accept terms on behalf of the signer.

This function returns whether the address is allowed to accept terms on behalf of the signer.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that can accept terms on behalf of the signer. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | bool | Whether the address is allowed to accept terms on behalf of the signer. |

setGlobalRenderer

function setGlobalRenderer(string _newRenderer) external

Function to set the Global Renderer.

This function lets the owner of the contract set the global renderer of the terms.

| Name | Type | Description | | ---- | ---- | ----------- | | _newRenderer | string | The new renderer to use for the terms. |

_setGlobalRenderer

function _setGlobalRenderer(string _newRenderer) internal

Function to set the Global Renderer.

This internal function sets the global renderer of the terms. It emits the GlobalRendererChanged event when renderer is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _newRenderer | string | The new renderer to use for the terms. |

renderer

function renderer() public view returns (string)

Function that returns the global renderer.

This function returns the global renderer of the terms.

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _globalRenderer The global renderer of the terms. |

setGlobalTemplate

function setGlobalTemplate(string _newDocTemplate) external

Function to set the Global Document Template.

This function lets the owner of the contract set the global document template of the terms.

| Name | Type | Description | | ---- | ---- | ----------- | | _newDocTemplate | string | The new document template to use for the terms. |

_setGlobalTemplate

function _setGlobalTemplate(string _newDocTemplate) internal

Function to set the Global Document Template.

This internal function sets the global document template of the terms. It emits the GlobalTemplateChanged event when template is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _newDocTemplate | string | The new document template to use for the terms. |

docTemplate

function docTemplate() external view returns (string)

Function that returns the global document template.

This function returns the global document template of the terms.

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _globalDocTemplate The global document template of the terms. |

setGlobalTerm

function setGlobalTerm(string _term, string _value) external

Function to set the Global Term/// @notice Explain to an end user what this does

This function lets the owner of the contract set the global terms

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term to set. | | _value | string | The value of the term to set. |

_setGlobalTerm

function _setGlobalTerm(string _term, string _value) internal

Function to set the Global Term

This internal function sets the global terms It emits the GlobalTermChanged event when term is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term to set. | | _value | string | The value of the term to set. |

globalTerm

function globalTerm(string _term) public view returns (string)

This function returns the global value of the term

This function returns the global value of the term

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term to get. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _globalTerms[_term] The global value of the term |

currentTermsBlock

function currentTermsBlock() public view returns (uint256)

Function to get block of the latest term change.

This function returns the block number of the last term change.

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | uint256 | _lastTermChange The block number of the last term change. |

setURI

function setURI(string _newURI) external

Function to set the contract URI

This function lets the owner of the contract or a metasigner set the contract URI. It emits UpdatedURI event when URI is updated.

| Name | Type | Description | | ---- | ---- | ----------- | | _newURI | string | The URI to set. |

URI

function URI() public view returns (string)

Function to get the contract URI

This function returns the contract URI.

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _uri The contract URI. |

TermsableNoToken

_hasAcceptedTerms

mapping(address => bool) _hasAcceptedTerms

Mapping that stores whether the address has accepted terms.

This mapping returns a boolean value indicating whether the address has accepted terms.

_acceptedTerms

function _acceptedTerms(address _to) internal view returns (bool)

This is an internal function that returns whether the address has accepted terms.

This function returns a boolean value indicating whether the address has accepted terms.

| Name | Type | Description | | ---- | ---- | ----------- | | _to | address | The address to check. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | bool | True if the address has accepted terms, false otherwise. |

acceptedTerms

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

This is an external function that returns whether the address has accepted terms.

This function returns a boolean value indicating whether the address has accepted terms.

| Name | Type | Description | | ---- | ---- | ----------- | | _address | address | The address to check. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | bool | True if the address has accepted terms, false otherwise. |

acceptTerms

function acceptTerms(string _newtermsUrl) external

This is an external function called by a user that wants to accepts the agreement at certain url

_This function is called by a user that wants to accepts terms. It checks if the terms url for the agreement is the latest one. It then updates the mapping hasAcceptedTerms and emits the AcceptedTerms event.

| Name | Type | Description | | ---- | ---- | ----------- | | _newtermsUrl | string | The url of the terms. |

acceptTermsFor

function acceptTermsFor(address _signer, string _newtermsUrl, bytes _signature) external

This function is used to accept the terms at certain url on behalf of the user (metasigner)

This function is called by a metasigner to accept terms on behalf of the signer that wants to accepts terms. It uses ECDSA to recover the signer from the signature and the hash of the termsurl and checks if they match.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that wants to accept terms. | | _newtermsUrl | string | The url of the terms. | | _signature | bytes | The signature of the signer that wants to accept terms. |

_acceptTerms

function _acceptTerms(address _signer, string _newtermsUrl) internal

This is an internal function called by a user that wants to accepts the agreement at certain url

_This function is called by a the external function which is called by a user that wants to accepts terms. It updates the mapping hasAcceptedTerms and emits the AcceptedTerms event.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that wants to accept terms. | | _newtermsUrl | string | The url of the terms. |

termsUrl

function termsUrl() external view returns (string)

This function returns the url of the terms.

This function returns the url of the terms with the prefix "ipfs://".

_termsUrl

function _termsUrl() internal view returns (string)

This internal function returns the url of the terms.

This internal function returns the url of the terms with the prefix "ipfs://".

termsUrlWithPrefix

function termsUrlWithPrefix(string prefix) external view returns (string)

This function returns the url of the terms with a given prefix

This function returns the url of the terms with the prefix

| Name | Type | Description | | ---- | ---- | ----------- | | prefix | string | The prefix of the url. return _termsUrlWithPrefix(prefix) The url of the terms with the prefix. |

_termsUrlWithPrefix

function _termsUrlWithPrefix(string prefix) internal view returns (string _termsURL)

This is an internal function that returns the url of the agreement with a given prefix.

This function returns the url of the agreement with the prefix. It uses the global renderer, template, chain id, contract address of the deployed contract and the latest block height to concatenate the url.

| Name | Type | Description | | ---- | ---- | ----------- | | prefix | string | The prefix of the url. |

| Name | Type | Description | | ---- | ---- | ----------- | | _termsURL | string | The url of the agreement with the prefix. |

TokenTermsable

hasAcceptedTerms

mapping(address => mapping(uint256 => bool)) hasAcceptedTerms

Mapping that stores whether the address has accepted terms for a specific token.

This mapping returns a boolean value indicating whether the address has accepted terms for a specific token.

_tokenTerms

mapping(string => mapping(uint256 => string)) _tokenTerms

This is mapping that store the URL for the agreeemnt for a specific token.

This mapping returns the URL for the agreement for a specific token.

_tokenDocTemplates

mapping(uint256 => string) _tokenDocTemplates

This is mapping that store the CID of the template for a specific token.

This mapping returns the CID of the template for a specific token.

_tokenRenderers

mapping(uint256 => string) _tokenRenderers

This is mapping that store the CID of the Renderer for a specific token.

This mapping returns the CID of the Renderer for a specific token.

_acceptedTerms

function _acceptedTerms(address to, uint256 tokenId) internal view returns (bool)

This is an internal function that returns whether the address has accepted terms for a specific token.

This function returns a boolean value indicating whether the address has accepted terms for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | to | address | The address to check. | | tokenId | uint256 | The token id to check. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | bool | hasAcceptedTerms[to][tokenId] True if the address has accepted terms for a specific token, false otherwise. |

acceptedTerms

function acceptedTerms(address to, uint256 tokenId) external view returns (bool)

This is an external function that returns whether the address has accepted terms for a specific token.

This function returns a boolean value indicating whether the address has accepted terms for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | to | address | The address to check. | | tokenId | uint256 | The token id to check. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | bool | _acceptedTerms(to, tokenId) True if the address has accepted terms for a specific token, false otherwise. |

acceptTerms

function acceptTerms(uint256 tokenId, string newtermsUrl) external

This is external function that the user can call to accept specific terms for a specific token.

This function accepts specific terms agreement mentioned on a URL for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the terms are accepted. | | newtermsUrl | string | The terms that are accepted. |

acceptTermsFor

function acceptTermsFor(address _signer, string _newtermsUrl, uint256 _tokenId, bytes _signature) external

This function is used to accept the terms at certain url on behalf of the user (metasigner) for a specific token.

This function is called by a metasigner to accept terms on behalf of the signer that wants to accepts terms for a specific token. It uses ECDSA to recover the signer from the signature and the hash of the termsurl and checks if they match.

| Name | Type | Description | | ---- | ---- | ----------- | | _signer | address | The address of the signer that wants to accept terms. | | _newtermsUrl | string | The url of the terms. | | _tokenId | uint256 | The token id for which the terms are accepted. | | _signature | bytes | The signature of the signer that wants to accept terms. |

_acceptTerms

function _acceptTerms(uint256 _tokenId, string _newtermsUrl) internal virtual

This is an internal function that the user can call to accept specific terms for a specific token.

This function accepts specific terms agreement on a URL for a specific token. It first checks if the terms the user is accepting are the latest terms for the token. If they are not, it throws an error. If they are, it accepts the terms (updates mapping) and emits the AcceptedTerms event.

| Name | Type | Description | | ---- | ---- | ----------- | | _tokenId | uint256 | The token id for which the terms are accepted. | | _newtermsUrl | string | The terms that are accepted. |

termsUrl

function termsUrl(uint256 tokenId) external view returns (string)

This is an external function that returns the URL for the agreement for a specific token.

This function returns the URL for the agreement for a specific token with prefix "ipfs://".

_termsUrl

function _termsUrl(uint256 tokenId) internal view returns (string)

This is an internal function that returns the URL for the agreement for a specific token.

This function returns the URL for the agreement for a specific token with prefix "ipfs://".

_termsUrlWithPrefix

function _termsUrlWithPrefix(uint256 tokenId, string prefix) internal view returns (string _termsURL)

This is an internal function that returns the URL for the terms agreement for a specific token.

This function returns the URL for the terms agreement for a specific token. It takes a prefix as an argument. It concatenates the prefix with tokenRenderer, tokenTemplate, chain Id, address of the contract, latest block height when the terms changed for that token and token Id.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the terms URL is returned. | | prefix | string | The prefix to be added to the URL. |

| Name | Type | Description | | ---- | ---- | ----------- | | _termsURL | string | The URL of the terms agreement for a specific token. |

termsUrlWithPrefix

function termsUrlWithPrefix(uint256 tokenId, string prefix) public view returns (string)

This is a public function that returns the URL of the agreement for a specific token.

This function returns the URL of the agreement for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the terms URL is returned. | | prefix | string | The prefix to be added to the URL. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _termsUrlWithPrefix(tokenId, prefix) The URL of the terms agreement for a specific token with a given prefix. |

setTokenTemplate

function setTokenTemplate(uint256 tokenId, string newTokenTemplate) external

This function can be called by the owner to set the CID of the template for a specific token.

This function sets the CID of the template for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the template is set. | | newTokenTemplate | string | The CID of the template for a specific token. |

_setTokenTemplate

function _setTokenTemplate(uint256 tokenId, string newTokenTemplate) internal virtual

This is an internal function that sets the CID of the template for a specific token.

This function sets the CID of the template for a specific token. It emits TokenTemplateChanged.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the template is set. | | newTokenTemplate | string | The CID of the template for a specific token. |

tokenTemplate

function tokenTemplate(uint256 tokenId) external view returns (string)

This function returns the CID of the template for a specific token.

This function returns the CID of the template for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the template is returned. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _tokenTempate(tokenId) The CID of the template for a specific token. |

setTokenRenderer

function setTokenRenderer(uint256 tokenId, string newRenderer) external

This is a function that can be called by the owner to set the CID of the renderer for a specific token.

This function sets the CID of the renderer for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the renderer is set. | | newRenderer | string | The CID of the renderer for a specific token. |

_setTokenRenderer

function _setTokenRenderer(uint256 tokenId, string newRenderer) internal virtual

This is an internal function that sets the CID of the renderer for a specific token.

This function sets the CID of the renderer for a specific token. It emits TokenRendererChanged.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the renderer is set. | | newRenderer | string | The CID of the renderer for a specific token. |

tokenRenderer

function tokenRenderer(uint256 tokenId) external view returns (string)

This function returns the CID of the renderer for a specific token.

This function returns the CID of the renderer for a specific token.

| Name | Type | Description | | ---- | ---- | ----------- | | tokenId | uint256 | The token id for which the renderer is returned. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _tokenRenderer(tokenId) The CID of the renderer for a specific token. |

_tokenRenderer

function _tokenRenderer(uint256 _tokenId) internal view returns (string)

This is an internal function that returns the CID of the renderer for a specific token.

This function returns the CID of the renderer for a specific token or the global renderer if the token renderer is not set.

| Name | Type | Description | | ---- | ---- | ----------- | | _tokenId | uint256 | The token id for which the renderer is returned. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _tokenRenderers[_tokenId] The CID of the renderer for a specific token or _globalRenderer if the token renderer is not set. |

_tokenTemplate

function _tokenTemplate(uint256 _tokenId) internal view returns (string)

This is an internal function that returns the CID of the template for a specific token.

This function returns the CID of the renderer for a specific token or the global template if the token template is not set.

| Name | Type | Description | | ---- | ---- | ----------- | | _tokenId | uint256 | The token id for which the template is returned. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _tokenDocTemplates[_tokenId] The CID of the template for a specific token or _globalDocTemplate if the token template is not set. |

setTokenTerm

function setTokenTerm(string _term, uint256 _tokenId, string _value) external

This function is used to set a value for a specific term for a specific token.

This function is used to set a value for a specific term for a specific token. It emits the the TokenTermAdded event and records the last time the terms were changed.

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term for which the value is set. | | _tokenId | uint256 | The token id for which the term is set. | | _value | string | The value for the term. |

_setTokenTerm

function _setTokenTerm(string _term, uint256 _tokenId, string _value) internal virtual

This is an internal function that sets a value for a specific term for a specific token.

This function is used to set a value for a specific term for a specific token. It emits the the TokenTermChanged event.

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term for which the value is set. | | _tokenId | uint256 | The token id for which the term is set. | | _value | string | The value for the term. |

tokenTerm

function tokenTerm(string _term, uint256 _tokenId) public view virtual returns (string)

This function is used to get the value for a specific term for a specific token.

_This function is used to get the value for a specific term for a specific token. If the term is not set for the specific token, it returns the global term value for the specific term.

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term for which the value is returned. | | _tokenId | uint256 | The token id for which the term is returned. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _tokenTerms[_term][_tokenId] The value for the term or the global term value if the term is not set. |

ERC721Termsable

_tokenIds

struct Counters.Counter _tokenIds

_uri

string _uri

MintNFT

event MintNFT(address sender, uint256 tokenId)

constructor

constructor(address _newOwner, string _name, string _symbol) public

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

_transfer

function _transfer(address from, address to, uint256 tokenId) internal virtual

_Transfers tokenId from from to to. As opposed to {transferFrom}, this imposes no restrictions on msg.sender.

Requirements:

  • to cannot be the zero address.
  • tokenId token must be owned by from.

Emits a {Transfer} event._

TermsInfo

struct TermsInfo {
  string key;
  string value;
}

setPolydocs

function setPolydocs(string renderer, string template, struct ERC721Termsable.TermsInfo[] terms) public

mint

function mint(string _tokenURI) public returns (uint256)

ERC721TokenTermsable

_tokenIds

struct Counters.Counter _tokenIds

_uri

string _uri

MintNFT

event MintNFT(address sender, uint256 tokenId)

constructor

constructor(address _newOwner, string _name, string _symbol) public

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

_transfer

function _transfer(address from, address to, uint256 tokenId) internal virtual

_Transfers tokenId from from to to. As opposed to {transferFrom}, this imposes no restrictions on msg.sender.

Requirements:

  • to cannot be the zero address.
  • tokenId token must be owned by from.

Emits a {Transfer} event._

tokenTerm

function tokenTerm(string _term, uint256 _tokenId) public view returns (string)

This function is used to get the value for a specific term for a specific token.

_This function is used to get the value for a specific term for a specific token. If the term is not set for the specific token, it returns the global term value for the specific term.

| Name | Type | Description | | ---- | ---- | ----------- | | _term | string | The term for which the value is returned. | | _tokenId | uint256 | The token id for which the term is returned. |

| Name | Type | Description | | ---- | ---- | ----------- | | [0] | string | _tokenTerms[_term][_tokenId] The value for the term or the global term value if the term is not set. |

TermsInfo

struct TermsInfo {
  string key;
  string value;
}

setPolydocs

function setPolydocs(uint256 _tokenId, string renderer, string template, struct ERC721TokenTermsable.TermsInfo[] terms) public

mint

function mint(string _tokenURI) public returns (uint256)