1.0.1 • Published 2 years ago

@polydocs/contracts v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.

NameTypeDescription
uristringThe 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

NameTypeDescription
_uristringThe 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.

NameTypeDescription
senderaddressThe address that accepted the terms.
termsstringThe 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.

NameTypeDescription
prefixstringThe prefix to add to the terms url.
NameTypeDescription
0stringThe terms url with the prefix.

termsUrl

function termsUrl() external view returns (string)

This function returns the terms url.

This function returns the terms url.

NameTypeDescription
0stringThe 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.

NameTypeDescription
_newtermsUrlstringThe 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.

NameTypeDescription
_signeraddressThe address of the signer that wants to accept terms.
_newtermsUrlstringThe url of the terms.
_signaturebytesThe 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.

NameTypeDescription
_addressaddressThe address of the user.
NameTypeDescription
0boolTrue 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

NameTypeDescription
_termbytes32The term being added to the contract
_valuebytes32value 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.

NameTypeDescription
_rendererstringThe 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.

NameTypeDescription
_templatestringThe 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

NameTypeDescription
_termstringThe term to get
NameTypeDescription
_valuestringThe 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

NameTypeDescription
senderaddressThe address that accepted the terms.
tokenIduint256The token id for which the terms are accepted.
termsstringThe 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.

NameTypeDescription
toaddressThe address to check.
tokenIduint256The token id to check.
NameTypeDescription
0bool_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.

NameTypeDescription
tokenIduint256The token id for which the terms are accepted.
newtermsUrlstringThe 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.

NameTypeDescription
_signeraddressThe address of the signer that wants to accept terms.
_newtermsUrlstringThe url of the terms.
_tokenIduint256The token id for which the terms are accepted.
_signaturebytesThe 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.

NameTypeDescription
tokenIduint256The token id for which the terms URL is returned.
prefixstringThe prefix to be added to the URL.
NameTypeDescription
0string_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.

NameTypeDescription
_termbytes32The term being added to the contract.
_tokenIduint256The token id of the token for which the term is being added.
_valuebytes32The 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.

NameTypeDescription
_tokenIduint256The token id of the token for which the renderer is being updated.
_rendererstringThe 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.

NameTypeDescription
_tokenIduint256The token id of the token for which the template is being updated.
_templatestringThe 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.

NameTypeDescription
_termstringThe term to get
_tokenIduint256The token id of the token for which the term's value is being returned.
NameTypeDescription
_valuestringThe 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

NameTypeDescription
owneraddressThe owner of the template
indexuint256The 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.

NameTypeDescription
_templatestruct TemplateRegistry.TemplateThe 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

NameTypeDescription
_indexuint256The index of the template to return
NameTypeDescription
0struct TemplateRegistry.TemplateThe 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

NameTypeDescription
_cidstringThe cid of the template to return
NameTypeDescription
0struct TemplateRegistry.TemplateThe 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

NameTypeDescription
_cidstringThe cid of the template to return the index of
NameTypeDescription
0uint256The 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

NameTypeDescription
_cidstringThe 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

NameTypeDescription
_cidstringThe 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

NameTypeDescription
_cidstringThe cid of the template to return the reputation score of
NameTypeDescription
0int256The 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.

NameTypeDescription
_signeraddressThe 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.

NameTypeDescription
_signeraddressThe 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.

NameTypeDescription
_signeraddressThe 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.

NameTypeDescription
_signeraddressThe 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.

NameTypeDescription
_signeraddressThe address of the signer that can accept terms on behalf of the signer.
NameTypeDescription
0boolWhether 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.

NameTypeDescription
_newRendererstringThe 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.

NameTypeDescription
_newRendererstringThe 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.

NameTypeDescription
0string_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.

NameTypeDescription
_newDocTemplatestringThe 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.

NameTypeDescription
_newDocTemplatestringThe 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.

NameTypeDescription
0string_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

NameTypeDescription
_termstringThe term to set.
_valuestringThe 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.

NameTypeDescription
_termstringThe term to set.
_valuestringThe 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

NameTypeDescription
_termstringThe term to get.
NameTypeDescription
0string_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.

NameTypeDescription
0uint256_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.

NameTypeDescription
_newURIstringThe URI to set.

URI

function URI() public view returns (string)

Function to get the contract URI

This function returns the contract URI.

NameTypeDescription
0string_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.

NameTypeDescription
_toaddressThe address to check.
NameTypeDescription
0boolTrue 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.

NameTypeDescription
_addressaddressThe address to check.
NameTypeDescription
0boolTrue 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.

NameTypeDescription
_newtermsUrlstringThe 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.

NameTypeDescription
_signeraddressThe address of the signer that wants to accept terms.
_newtermsUrlstringThe url of the terms.
_signaturebytesThe 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.

NameTypeDescription
_signeraddressThe address of the signer that wants to accept terms.
_newtermsUrlstringThe 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

NameTypeDescription
prefixstringThe 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.

NameTypeDescription
prefixstringThe prefix of the url.
NameTypeDescription
_termsURLstringThe 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.

NameTypeDescription
toaddressThe address to check.
tokenIduint256The token id to check.
NameTypeDescription
0boolhasAcceptedTermsto 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.

NameTypeDescription
toaddressThe address to check.
tokenIduint256The token id to check.
NameTypeDescription
0bool_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.

NameTypeDescription
tokenIduint256The token id for which the terms are accepted.
newtermsUrlstringThe 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.

NameTypeDescription
_signeraddressThe address of the signer that wants to accept terms.
_newtermsUrlstringThe url of the terms.
_tokenIduint256The token id for which the terms are accepted.
_signaturebytesThe 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.

NameTypeDescription
_tokenIduint256The token id for which the terms are accepted.
_newtermsUrlstringThe 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.

NameTypeDescription
tokenIduint256The token id for which the terms URL is returned.
prefixstringThe prefix to be added to the URL.
NameTypeDescription
_termsURLstringThe 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.

NameTypeDescription
tokenIduint256The token id for which the terms URL is returned.
prefixstringThe prefix to be added to the URL.
NameTypeDescription
0string_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.

NameTypeDescription
tokenIduint256The token id for which the template is set.
newTokenTemplatestringThe 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.

NameTypeDescription
tokenIduint256The token id for which the template is set.
newTokenTemplatestringThe 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.

NameTypeDescription
tokenIduint256The token id for which the template is returned.
NameTypeDescription
0string_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.

NameTypeDescription
tokenIduint256The token id for which the renderer is set.
newRendererstringThe 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.

NameTypeDescription
tokenIduint256The token id for which the renderer is set.
newRendererstringThe 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.

NameTypeDescription
tokenIduint256The token id for which the renderer is returned.
NameTypeDescription
0string_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.

NameTypeDescription
_tokenIduint256The token id for which the renderer is returned.
NameTypeDescription
0string_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.

NameTypeDescription
_tokenIduint256The token id for which the template is returned.
NameTypeDescription
0string_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.

NameTypeDescription
_termstringThe term for which the value is set.
_tokenIduint256The token id for which the term is set.
_valuestringThe 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.

NameTypeDescription
_termstringThe term for which the value is set.
_tokenIduint256The token id for which the term is set.
_valuestringThe 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.

NameTypeDescription
_termstringThe term for which the value is returned.
_tokenIduint256The token id for which the term is returned.
NameTypeDescription
0string_tokenTerms_term 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.

NameTypeDescription
_termstringThe term for which the value is returned.
_tokenIduint256The token id for which the term is returned.
NameTypeDescription
0string_tokenTerms_term 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)
1.0.1

2 years ago

1.0.0

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago